886 - EECS_I2P(I)2015_Chen_Mid_2 Scoreboard

Time

2015/12/09 08:00:00 2015/12/09 09:50:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10850 license
10865 Simple Tangram(Triangle Only)
10866 Pour Water (Stones Surrounded)

10850 - license   

Description

There are N license. Each license has four-digit integer, each integer between 1 to 9. For example, if N=7, the input may look like

7

1324

5566

3578

4123

5656

4312

9847

We want to get the licenses that use the same digits and the digits should be sorted from small to large. For example, 1324, 4123, and 4312 are the combination of the same digits (1, 2, 3, and 4). We want to get 1234. Similarly, 5566 and 5656 are the combination of the same digits (5, 5, 6, and 6). We want to get 5566. 

For output, we list the modified licenses in an increasing order line by line, so the output will look 

1234

5566

 

<Hint>

You may consider the following algorithm:

0. Create a character array (char str[5];) for storing the input integers and create an array which is initialed to zero (int HIT[10000];) to record the occurrences of input integers.

1. Read the number of input integers and store it in variable N (scanf("%d", &N);).

2. For each of the next N integers, do 

    2.1 Read the four-digit integer and store it as a four-character string in str.

    2.2 Use the bubble sort algorithm to rearrange the four characters.

    2.3 Convert the rearranged string to an integer m and increase the value of the corresponding element of the HIT array by 1 (HIT[m]++;).

3. Check each element of the HIT array; if its value is larger than 2, print the corresponding integer.

 

The bubble sort algorithm:

/* Using bubble sort to rearrange an array A[n] */

for (i = n; i > 0; i--) {

   for (j = 1; j < i; j++) {

      if (A[j-1] > A[j]) {

         /* swap A[j-1] A[j] */

      }

   }

}

Input

The first line contains a number N (1<=N<=100).

The next N lines provide the N four-digit integers.

Output

Each line shows a modified unique integer as explained in the problem description.

Remember to print a newline at the end of each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10865 - Simple Tangram(Triangle Only)   

Description

The tangram is a dissection puzzle consisting of seven flat shapes, called tans, which are put together to form shapes. For example, we can use the given seven tans to form a bird as follows:

In this problem, let’s play a simplified tangram. You are asked to form a shape on a M*N (0<M,N≦50) board, which is initially plotted a symbol ’-’ at each location. Now, we consider only one tans as follows:

  • You will be given a symbol (Triangle (T) ) representing the desired tan, the rotated angle(only 0, 90, 180 or 270 degrees), the height of the tan, and the assigned coordinate of the tan’s vertex(頂點).

Specifically, when rotating a tan, the tan is fixed at its vertex, and rotated clockwise (by degrees 0, 90, 180, or 270.)

For example:

Input

The input contains several lines. The first line contains two numbers representing the board’s height and width. The following line contains one symbol and four numbers. The first symbol represents the tan you should put on board. The second number represents the rotating degree of the tan. The third number represents the height or side of the tan. The fourth and fifth numbers represent the coordinate of the tan’s vertex.

An input line containing only ’x’ represents the end of the input.

Output

The output should print the M*N board. Note that there's a '\n' at the end of last line.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10866 - Pour Water (Stones Surrounded)   

Description

A farmer has a crop land. The land consists of stones (S) and holes (H) as illustrated in the following figure. Note that the crop land is surrounded by the stones(S), so no need to worry about that water may flooding outside th crop land.

The farmer decides to water his crops, so he pours some water through the hole  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 (1,3) representing the entrance and a table representing the farmer’s land initially:

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.

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 four 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 Y (0<=Y<=R-1) means the row of the entrance. The forth integer X (0<=X<=C-1) means the column of the entrance. The coordinate of the entrance is thus (Y,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

10866.c

Partial Judge Header

10866.h

Tags




Discuss