1563 - I2P18_EECS_Mid_2_make_up Scoreboard

Time

2018/12/17 08:00:00 2018/12/17 10:20:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10308 2048
10368 mid2補考_problem1
12081 CS_2018_MID2-2
12083 CS_2018_MID2-4

10308 - 2048   

Description

The game of 2048 is very simple. Given a 4x4 map containing tiles and spaces. The values are displayed on the tiles, and the spaces are displayed as 0. The values of tiles are always the power of 2. For example,
    2    2   64  128
    4    0    4   16
    4    4    4    4
    0    0    2    0

is a valid map.

We are able to slide the tiles in the only down direction. The rules of sliding are defined as follows:
1. All tiles slide past spaces. If you move the puzzle to the bottom, all spaces will end up on the top.
2. After sliding to collapse spaces, any tiles with the same value combine and the remainder of the column slides to fill in the hole.
3. One tile can only combine(be combined) once.
4. The combination always starts from the bottom.
5. Contrary to the famous game of 2048, there are no new tiles generated.

For instance, if we have the map above, after we slide the tiles once, the map becomes
    0    0    0    0
    0    0   64  128
    2    2    8   16
    8    4    2    4


Your job is to output the number of spaces for each column after sliding the tiles.

Hint:

#include <stdio.h>

#define WIDTH 4
#define HEIGHT 4

int map[HEIGHT][WIDTH];

void collapse(){
    /* your code here */
}

void slide(){
    /* your code here */
}

void show(){
    /* your code here */
}

int main()
{
    int N, d;
    int i, j;

    scanf("%d", &N);
    for(i = 0; i < HEIGHT; i++){
        for(j = 0; j < WIDTH; j++){
            scanf("%d", &map[i][j]);
        }
    }

    for(i = 0; i < N; i++){
        slide();
    }

    show();

    return 0;
}

Input

N (the count of slides)
The map

Output

The number of spaces of each column

Use "%d " to print each number. Print a newline '\n' at the end.
Note that the value of tiles will not exceed 8192.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10368 - mid2補考_problem1   

Description

The input contains two polynomials f(x) and g(x).
f(x) = amxm + a(m-1)x(m-1) + ⋯ + a1x1 + a0x0
g(x) = bnxn + b(n-1)x(n-1) + ⋯ + b1x1 + b0x0

where m,n∈N, 0≤m,n≤10.

Compute h(x) = f(x)g(x).
Note that all the coefficients are integers.

Input

m
am a(m-1)  … a1 a0
n
bn b(n-1)  … b1 b0


Note that the coefficients are separated by a blank.

Output

The coefficients of h(x) in descending power order.
Use "%d " to print each coefficient and there is a newline at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12081 - CS_2018_MID2-2   

Description

Compute the numbers of islands on the map.
The character '~' means water. There are two types of islands, denoted as '#' and '@'.
Take the following map for example:

The number of #-typed islands is 3, and the number of @-typed islands is 2.

Note that two '#'s are considered connected only if they are horizontal or vertical neighbors. Diagonal neighbors are not considered connected. The rule is the same for '@'.

Input

The first line contains two integers m, n, representing the height and width of the map.

The next m lines contain n characters for the mth row of the map.

It is guaranteed that 1 ≤ m, n ≤ 1000

Output

Print the number of islands for '#' and the number of islands for '@'.

The two numbers are separated by a whitespace. Please include a newline character '\n' at the end of the output.

Sample Input  Download

Sample Output  Download

Tags




Discuss




12083 - CS_2018_MID2-4   

Description

You want to stimulate shooting route in a room. You know the boundary of room, the start point of a shooting object, and the direction of shooting. When the object hitting the boundary, it would reflect with 45 degrees. Your mission is to show the route of the shooting object.

 

Input

The first line has three numbers, CF and H, which respectively means the length of the ceiling, the length of the floor, and the height between the ceilings and floors.

The second line has a number S, which means the start point of shooting object. It's noted that the location below the ceiling is 1, and the location below that is 2, and so on.

  • 1 ≤ C, F ≤ 20
  • 2 ≤ H ≤ 20
  • 1 ≤ S ≤ H

The third line has a character 'u' or 'd'. It  corresponds to the initial direction of shooting.

  • u: upper-right in 45 degree
  • d: lower-right in 45 degree

There are only one case for each testcase

Output

Draw the map and the route of the shooting object.
The route of shooting object is marked as '*', which appears until the object is out of boundaries.

You need to use a (H+2)*(max{C, F, the horizontal length of the route of shooting}) array to print out the result

Remember there is '\n' in the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss