1110 - I2P CS 2016 Chen Lab5 Scoreboard

Time

2016/12/22 13:20:00 2016/12/22 15:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
11273 Name and Height
10308 2048

11273 - Name and Height   

Description

Given a set of names and numbers , please sort them seperately and print out !

1. You should sort the names in alphabetical order .

    In alphabetical order , "A" has the highest priority and "Z" has the lowest priority.

    For example , if there are 3 names : Bruce , Adam , Wendy , Alex .

    You should print the names in order : Adam , Alex , Bruce , Wendy.

    Because "A" has the highest priority , you should print out the names beginning with "A"

    Because "d" has higher priority than " l " , you should print out Adam before Alex

 

2. You should sort the numbers in acsending order . 

3. If you encounter Time Limit Exceeds (TLE) , you can use "qsort" to speed up your program

Input

The first line contains an integer N , indicating the number of people. (2 <=N<=80) 

There are following 2N lines.

There are N names in 2nd ~ N+1 th lines . Each lines contains a name. (3<= length of name <=20)

There are N integers in N+2 th ~ 2N+1 th lines . Each lines contains an integer indicating the height of somebody

Output

Print out the name in alphabetical order and height in acsending order .

1. Output format : printf("%s %d\n",NAME,HEIGHT) ;

Sample Input  Download

Sample Output  Download

Tags




Discuss




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