1562 - I2P (I) 2018_Yang_practice_Final Scoreboard

Time

2018/12/24 18:00:00 2019/01/07 15:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10848 Pour Water
11238 Light Reflection
11290 Moving Cars(4 direction)
11291 Mouse Maze
11490 The Cat Society
11773 Integer pointer array
11774 Reverse Linked List
12099 String sorting

10848 - Pour Water   

Description

A farmer has a crop land. The land consists of stones (S) and holes (H) as illustrated in the following figure. Note that there is only one hole on the land’s first row.

S

S

H

S

S

H

S

H

H

H

H

H

H

S

S

H

H

S

H

H

H

S

S

S

S

 

The farmer decides to water his crops, so he pours some water through the hole on the first row into the land. Assume that the amount of water is infinite, and the water can move in the four directions: up, down, left, right. Please write a program to find out where the water would reach.

For example, you are given a coordinate (0,2) representing the entrance and a table representing the farmer’s land initially:

S

S

H

S

S

H

S

H

H

H

H

H

H

S

S

H

H

S

H

H

H

S

S

S

S

 

After the farmer pours water into the land, water floods throughout the holes of the land. Finally, a portion of the holes will be filled with water like the following table.

S

S

W

S

S

W

S

W

W

W

W

W

W

S

S

W

W

S

H

H

W

S

S

S

S

 

where W means the corresponding hole is filled with water.

Note that

1.      This problem involves three files.

  • function.h: Function definition of flooding.
  • function.c: Function describe of flooding.
  • main.c: A driver program to test your implementation.

You will be provided with main.c and function.h, and asked to implement function.c.

2.     For OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose c compiler) 

       Step 2. Check the results and debug your program if necessary.

Hints:

function.h

main.c

 

Input

The first line has an integer N(1<=N<=100), which means the number of test cases.

For each case, the first line has three integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of row and column of the land, respectively. The total number of elements in the land is thus R x C. The third integer X (0<=X<=C-1) means the column of the entrance at the first row. The coordinate of the entrance is thus (0,X). The following R lines, each containing C characters, specify the elements of the farmer’s land.

Output

Print out all elements of the lands row-by-row, and there is a '\n' at the end of each line. The states of all lands should be separated by a new line character (\n).

Sample Input  Download

Sample Output  Download

Partial Judge Code

10848.c

Partial Judge Header

10848.h

Tags




Discuss




11238 - Light Reflection   

Description

Consider a room of size H*W (3<=H,3<=W) in which its four walls are covered by mirrors. You need to simulate the light reflection in the room and print out the k-th reflection point.

We assume that the light is always emitted from the left mirror and moves in the upper-right direction at an angle of 45 degrees. More specifically, the starting point can be represented by (r, 1) where 1<r<H. The light will stop if it hits any corner of the room . 
 

For example, if the room size is 5*6 and the light starts at (3,1), then the first point it hits is (3,1), the second point is (1,3), the third point is (4,6), and so on. If k=3 you need to print out (4,6).

If the light hits a corner before the k-th reflection, you need to print out coordinate of that corner. For example, if k =10 and the first point is (3,1), you need to print out (1,1) because the light stops at (1,1).

Input

The first line is the height and width of the room.

The second line is the starting point (the first reflection point).

The third line is k, which means you need to print out the k-th reflection point.

Output

The coordinate of the k-th reflection point.

Note that you DO NOT need to print a newline character ‘\n’ at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11290 - Moving Cars(4 direction)   

Description

Given the position of N cars on a map, we have to list the valid moves of each car along 4 directions (i.e. right, down, left and up).

Note that all cars can move horizontally and vertically.

For example, a map with 10 cars is shown below:

Given the coordinate of car 2 is 2 3 2 6, it means car 2 occupies the position of (2,3) to (2,6) in the map.

The valid moves of car 2 is 1 0 0 2, which means it can move right 1 grid but can’t move down, left and it can move up 2 grid.

 

HINTS:

function.h

#ifndef FUNCTION_H
#define FUNCTION_H
#define MAP_SIZE 9
#define MAX_CARS 10
#define SPACE '.'

char map[MAP_SIZE][MAP_SIZE];
int cars[MAX_CARS][4];
void list_moves(int);
#endif

main.c

#include <stdio.h>
#include "function.h"
int main(void)
{
    int i,j,k;
    int num_cars;

    scanf("%d",&num_cars);
    //reset map
    for (i=0; i<MAP_SIZE; i++) {
        for (j=0; j<MAP_SIZE; j++) {
            map[i][j] = SPACE;
        }
    }
    //read coordinates of cars and put them on the map
    for (i=0; i<num_cars; i++) {
        scanf("%d%d%d%d", &cars[i][0], &cars[i][1], &cars[i][2], &cars[i][3]);
        for (j=cars[i][0]; j<=cars[i][2]; j++) {
            for (k=cars[i][1]; k<=cars[i][3]; k++) {
                map[j][k] = i+'0';
            }
        }
    }
    list_moves(num_cars);

    return 0;
}

 

Input

The first line is a number N (1<=N<=10), which means the total number of cars.

The following N lines are the coordinates of all cars.

Each line consists of 4 numbers. The first two numbers are the row and column of the head of the car. The other two numbers are the row and column of the tail of the car.

Output

Print out the valid moves of the cars in each line.

Each line consists of 4 number, the valid moves along right, down, left and up.

All of the numbers in the same line are separated by a space, and there is a '\n' at the end of each line.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11290.c

Partial Judge Header

11290.h

Tags




Discuss




11291 - Mouse Maze   

Description

Write a program that simulates a mouse in a maze. The program must count the steps taken by the mouse from the starting point to the final point.

The maze type is shown in following figure:

S$###
$$#$$
$$$##
##$$F

it consists of S (starting point), #(walls), $(road) and F (final point).

In above case, it needs 7 steps from S to F as following figure,

S$###
$$#$$
$$$##
##$$F

and the mouse can move in the four directions: up, down, left, right. There may be more than one way to reach final point, the program only need to print the least steps.

If there is no way from S to F, then print -1.

Input

The first line has an integer N(1<=N<=10^6), which means the number of test cases.

For each case, the first line has two integers. The first and second integers R and C (3<=R, C<=500) represent the numbers of rows and columns of the maze, respectively. The total number of elements in the maze is thus R x C.

The following R lines, each containing C characters, specify the elements of the maze.

Output

Print out the least steps for each case, and there is a new line character at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




11490 - The Cat Society   

Description

Wild cats take care of each other in the wild. However, when winter comes, the preys are not enough to feed all the cats. Therefore, the cats dine according to the order of their occupations. The order is as follows:
1. elder
2. nursy
3. kitty
4. warrior
5. apprentice
6. medicent
7. deputy
8. leader

In the tradition of the cat society, three different cats serve as the medicent, the deputy, and the leader respectively.
As for the other cats, except that the apprentices have the dining priority of the young over the old, for the other occupations, the old have higher priority. If the occupations and the ages of two or more cats are the same, they will dine in lexicographic order according to their names.

Input

There are multiple test cases.

The first line of each test case contains two integers N and M, indicating the number of cats and the portions of food respectively, where 0<N,M<=10000.

The next N lines are the information of each cat, including name, occupation, and age.
The length of the names will not exceed 30 letters and will contain no spaces.

 

Output

Please output the cats that could eat the food in order, each name a line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss




11773 - Integer pointer array   

Description

Given an integer pointer array **ptr with size N, and an integer array *array with size (N+1)*N/2. Please use malloc function to allocate memory to **ptr and *array. The *array is an ascending sequence of numbers. Each pointer in array **ptr shall point to one element of *array. And the elements pointed by the **ptr are also ascending.

 

For example, when n = 5, the size of **ptr will be 5, and the size of *array will be 15. The first pointer of **ptr is *ptr[0] which points to array[0], and the second pointer of **ptr is *ptr[1] which points to array[1], and the third pointer of **ptr is *ptr[2] which points to array[3], and the fourth pointer of **ptr is *ptr[3] which points to array[6].

Input

The first line is size of **ptr

The second line is offset

offset < size <10000

Output

Print each pointer of **ptr + offset

Note that you need to print a newline character ‘\n’ after each number, that is, just one number will be shown in each line of the output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11773.c

Partial Judge Header

11773.h

Tags

This is a Partial Judge Problem



Discuss




11774 - Reverse Linked List   

Description

Given a linked list, you have to reverse it and output the result.

You have to implement four function:

1. Node* Create_List(Node*, int);

This function is used to create the linked list according to the input.

2. Node* Reverse_List(Node*);

This function is used to reverse the given linked list.

3. void Print_List(Node*);

This function is used to print out the key value in the linked list.

4. void Free_List(Node*);

This function is used to free the memory space.

Input

The first line contains one integer n, representing the number of nodes in the linked list.

The next line contains n integers, each of which represents a node in the linked list.

It is guaranteed that :

  • 1 ≤ n ≤ 10
  • 0 ≤ ai ≤ 100

Output

You need to output the reversed linked lists.

Each key value is separated by "->".

Note: remember to print a '\n' at the end of output.

Sample Input  Download

Sample Output  Download

Partial Judge Code

11774.c

Partial Judge Header

11774.h

Tags




Discuss




12099 - String sorting   

Description

Given several strings, please output them in alphabetical order.

 

Input

Input consists of several lines, each of them is a string.


It is guaranteed that

  • # of strings won't exceed 200000
  • Length of each string won't exceed 100

Output

Print out strings in alphabetical order, one string per line.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss