673 - I2P2014_Exercise_Final Scoreboard

Time

2014/09/18 00:00:00 2014/12/18 00:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10380 Enemy at the gates
10381 Pushing box
10382 palindrome
10383 draw a picture
10384 Search Engine
10389 Text Editor
10390 How to move?
10392 Sparse Vectors

10380 - Enemy at the gates   

Description

The kingdom of far worse is in trouble.

The enemies are going to attack kingdom of far worse.

 

The enemies have map of kingdom of far worse. The map shows that there are exactly some cities.

They are planning to isolate some cities of kingdom of far worse and their method is bomb some roads.

 

For example, there is a road between city 2 and city 3.

If the position of a bomb is (2, 3), the road from city 2 to city 3 will be destroyed by the bomb but there is still a road from 3 to 2.

 

The king of kingdom of far worse request you to write a program to show that which city does NOT have road can leave or enter it.

 

Note:

Below is a real map and its representation of 2-D array. Left-up is (1, 1).

 

For example of left part.

(1, 4) is 1, means there is a road from 1 to 4.

(4, 3) is 1, means there is a road from 4 to 3

(1, 2).is 0, means there is NO road from 1 to 2.

 

Input

One number N, N is the number of cities. 2 <= N <= 50

Following is a 2-D array map with N columns and N rows.

One number B, B is the number of bombs. 1 <= B <= N2

Following is B lines, each line is the position of bomb.

 

Output

Which city does NOT have road can leave or enter it.

The order of number is increasing. Each number is printed by format "%d\n" 

Sample Input  Download

Sample Output  Download

Tags




Discuss




10381 - Pushing box   

Description

The game is played on a board of squares, where each square is a floor, which is marked as ‘ ‘, or a wall, which is marked as ‘#’. Some floor squares contain boxes which are marked as ‘B’, and some floor squares are marked as storage locations, which is marked as ‘S’.

The player, which is marked as ‘P’, is confined to the board, and may move horizontally or vertically onto empty squares (never through walls or boxes). The player can also move into a box, which pushes it into the square beyond. Boxes may not be pushed into other boxes or walls, and they cannot be pulled. The puzzle is solved when all boxes are at storage locations.
 
We will first give a map which contains the positions of walls and storage locations. The size of the map is 10 x 10. And we will give you the position of the player. We will use U, D, R, and L, represent up, down, right, and left. The following M instructions will use those words to point out where the player should move. Finally, we have to print out the map and show the number of boxes which are at the storage locations.
 
[Note] If the box is on the storage location. You have to print B instead of S. If the player is on the storage location. You have to print P instead of S.

Input

Read the 10 x 10 map first. (The left-up position is (0, 0) )

Read the position of the player.

Read an integer M which indicates the number of direction instructions.

The next M lines contain the direction instructions.

Output

The number of boxes which are at the storage locations.

The 10 x 10 map.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10382 - palindrome   

Description

In this problem:

1. you are given a string which consists only of digit characters ‘1’ to ‘9’;

2. reorder the string to form palindromes; (A palindrome (回文) is a word, phrase, number, or other sequence of characters which reads the same backward or forward.)

3. among all the possible palindromes, find the one with the smallest integer value.

 

Consider the following two examples:

EX1: (total digits are even):

Input:       188126447672

Possible palindromes: 214678876412, 124678876421, 421678876124…

Output:  124678876421

 

EX2: (total digits are odd):

Input:      1881264247672

Possible palindromes: 2146782876412, 1246782876421, 4216782876124…

Output:  1246782876421

 

Input

The input is a string which consists only of digit characters ‘1’ to ‘9’. The string length will less and equal then 100.

Output

The output contains two lines. The first line prints out “YES” or “NO” indicating whether the input string can be reordered to form a palindrome. If the output is “YES”, the second line is the smallest palindrome. Otherwise, if the output is “NO”, the second line is the original string.

Remember to print a '\n' at the end of the answer.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10383 - draw a picture   

Description

 Let’s draw a picture on a 15*20 board which is initially plotted a symbol ’-’ at each location. We consider only three patterns as follows:   

You will be given a symbol (cross (x), intersection (+) or square (s)) representing the desired pattern, the radius or side of the pattern, and the assigned coordinate of the pattern’s center point.

 

There are some points that you should know.

1.      You should check if the pattern you draw crosses the boundary of the board. The part which is beyond the board should be ignored.

For example:

2.      If a later pattern overlaps an existing pattern, the later pattern will replace the existing one within the overlapping area.

For example:

3.      For a square pattern, you will be given only an odd number as its side.

You may use the following piece of code:

#include #include 
#define LENGTH 15
#define WIDTH 20

void cross(int r, int x, int y);
void intersection(int r, int x, int y);
void square(int r, int x, int y);
void printboard();

char board[LENGTH][WIDTH];
int i,j;

int main(){

    char symbol;
    int radius,row,col;

    for(i=0;i
  

Input

The input contains several lines. Each line contains one symbol and three numbers. The first symbol represents the pattern you should draw. The second number represents the radius of the pattern. The third and fourth numbers represent the coordinate of the pattern’s center point.

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

Output

The output should print the 15*20 board.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10384 - Search Engine   

Description

The most sample search engine is counting how many times a word appear in a page and gives you a page which is including the most number of word you search.

Now, give you a table of page name and the word it includes and a sentence which user want to search.

Finally, your program should tell user which page is most possible he or she wants

Input

Two number, N and S.  2<= N, S <= 20

N is number of pages.

S is number of keyword in each pages and each one is been parted by space.

Following is N line and each line contain S+1 word. First word is the name of page.

Finally, there is a sentence user want to search and the number of words is between S and (N*S)/2.

Note: All words are less than 15 characters and is lower case. There are no punctuations. There is no newline at end of sentence user want to search

Output

Output the name of page which has most key words.

If there are many page have same number of keywords, print out all of them in input order.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10389 - Text Editor   

Description

In this problem we simulate a simple text editor. Given a series of keyboard input, output the final text content.
The text editing rules are defined as following:
1. Normal alphabetical input and whitespace input (abcdefg…. and ‘ ‘) directly write  after the cursor of the text content.
And four special commands started with a backslash(/) character
2. The backspace command which deletes a letter before the cursor (/backspace)
3. The newline command which creates a new line after the cursor (/newline)
4. The two navigating commands which move the cursor (/left /right)

The size of the text content is fixed to 500 characters, and the text content of testcases will not exceed 500 characters when simulating.

Hint:

#include 

#define MAX_SIZE 500

char content[MAX_SIZE];
char input[MAX_SIZE];

int main()
{

    fgets(input, MAX_SIZE, stdin);

    /* your code here */

    printf("%s", content);

    return 0;
}

Input

The keyboard input sequence.
There is always a valid command(/backspace /newline /left /right) right after the backslash character.
There is no newline character at the end

Output

The final text content.
 

Sample Input  Download

Sample Output  Download

Tags




Discuss




10390 - How to move?   

Description

Suppose we have an NxN map. N=2k+1 The map consists of numbers 1~99.
For example,M=
75    69    81    43    49
73      3    68    37    44
38    27    31    72    63
64      4    94    78    70
16      9      3    18    74


we walk t step
Now, start walking from the center of map M(k+1,k+1)(in the example is 31)
the next position is determined by the number which we stand
Use number mod 4 to choice direction
Directions (Right:mod=0, Down:mod=1, Left:mod=2, Up:mod=3)
if next position is not on the map,next step we will not move

Input

t(number of move) n(size of map)
Map

note that there is a blank between neighbor elements in each row of Map.

Output

print the number we visit by sequence(t+1 numbers), where there is a blank space between neighbor numbers and no new line at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10392 - Sparse Vectors   

Description

Given two vectors, compute their dot product. The dot product is the sum of the product of the corresponding components of the two vectors. For example, the dot product of [1,2,3] and [4,5,6] is 32 because 1*4+2*5+3*6 = 32.

We may represent a high-dimensional sparse vector using the following format:
dim1:value1 dim2:value2 dim3:value3 … dimN:valueN 0:0
where 0:0 denotes the end of the vector.

An example: The vector [0,5,0,0,9,0,0,33] is an eight-dimensional vector, which can be represented as
2:5 5:9 8:33 0:0
That is, we may omit all dimensions whose values are zero. Such a representation is compact and particularly suitable for high-dimensional sparse vectors.

Note that the dimensions may be presented in arbitrary order. For example, the above vector may also be expressed as
8:33 2:5 5:9 0:0
 

Input

The input has two lines. Each line contains a vector of integer values represented in the sparse format. The usage of memory is limited to 32 MB. The dimension of the vector is no greater than 2 to the 31th power, and the N of dimN will not exceed 2 to the 20th power.

 Note that the nonzero dimensions may be presented in arbitrary order. For example, 
8:33 2:5 5:9 0:0

Output

The output is the dot product of the two input vectors. The answer should be printed in one line with a newline character at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss