682 - CS135502_I2P2014_Final Scoreboard

Time

2015/01/12 15:30:00 2015/01/12 19:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10414 Problem1
10415 Problem2
10416 Problem3
10417 Problem4
10418 Problem5

10414 - Problem1   

Description

Let’s draw a picture with symbol ‘*’ on a 10*10 board which is initially plotted a symbol ’-’ at each location. We consider four different line patterns (down(D)/up(U)/left(L)/right(R)) as follows:

You will be given the coordinate of the pattern’s starting point, the direction of the pattern and the length of the pattern.

There is a point 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:

You may use the following piece of code:

#include 
#define SIZE 10

void printboard();
char board[SIZE][SIZE];
int i,j;

int main(){

    int n,row,col,len;
    char dir;

    for(i=0;i
  

Input

The input contains several lines. The first line contains number N which represents the total number of patterns that you should draw. Each of the remaining lines contains the coordinate of the pattern’s starting point, the direction of the pattern and the length of the pattern.

Output

The output should print the 10*10 board.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10415 - Problem2   

Description

Consider a 7x14 map, where each position on the map has a value of 0, 1, 2, or 3 indicating the moving direction for that position. The representation: 0 for up, 1 for right, 2 for down, and 3 for left..
For example:
1 2 3 0 1 2 3 1 2 3 0 1 2 3
0 1 2 3 3 2 1 1 2 3 0 1 2 3
1 1 2 2 3 3 0 1 2 3 0 1 2 3
2 2 3 3 0 0 1 1 2 3 0 1 2 3
1 1 2 2 3 3 0 1 2 3 0 1 2 3
2 2 3 3 0 0 1 1 2 3 0 1 2 3
2 2 3 3 0 0 1 1 2 3 0 1 2 3

Start from the upper-left corner, follow the moving direction denoted by the value at each position. Stop when you reach the boundary of the map or when you reach a position that has been visited. Print the total number of visited positions, which should be 12 for the above example.

Complete the program by replacing ??? with correct code:

#include 
#define ROWS 7
#define COLS 14
int map[ROWS+2][COLS+2];
int visited[ROWS+2][COLS+2];
int main(void)
{
    int i, j, direction, num;
    int d_row[] = { ??? , ??? , ??? , ??? };
    int d_col[] = { ??? , ??? , ??? , ??? };

    for (i=0; i
  

Input

The 7x14 map.

Output

Print the total number of visited positions.
Newline character at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10416 - Problem3   

Description

This is a problem about a hungry spider eating insects. You will be given a 5*5 board on which several fixed insects stay at some locations. You will also be given the insects’ weight and the spider’s initial weight. The spider will move to these specific locations to eat the insects by the following rules:
1. If the weight of an insect is less than that of the spider, the spider can eat the insect and increase its weight by including the insect’s weight.
2. If the weight of an insect is heavier than that of the spider, the spider will be scared so as to lose half of its weight.
3. If the weight of an insect is equal to that of the spider, the spider will return to its initial weight.
After given N moves, calculate the spider's weight.

Note:
1. The coordinate of the upper-left corner is (0,0).
2. You don’t need to consider the case that the spider moves to same locations for multiple times.

You may use the following piece of code:

#include 
int main(void){

    int move,i,j;
    int map[5][5] = {0};
    float weight;

    for(i=0;i<5;i++)
        for(j=0;j<5;j++)
            scanf("%d",&map[i][j]);

    scanf("%f",&weight);
    scanf("%d",&move);

    /*your code*/

    printf("%.1f\n",weight);
    return 0;
}

Input

5*5 board
the initial weight of the spider
N (moves)
the destination coordinate after the first move
the destination coordinate after the second move

the destination coordinate after the Nth move

Output

The weight of the spider.
You should print the newline character at the end.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10417 - Problem4   

Description

Consider a string that contains alphabetical characters such as abcd… or ABCD... without whitespaces. The length of the string is less than 80.
The task: Given substring, delete it from the input string. Assume that the occurrence of the substring is exact one.
For example, if the input string is "CatDoGDogCatcatDOG", and the substring to be deleted is "Dog", then the output should be " CatDoGCatcatDOG ".

#include 
#include 
#define MAX_LEN 80
char input[MAX_LEN];
char subs[MAX_LEN];
char output[MAX_LEN];
int main(void)
{
    int i, j, k, match;
    scanf("%s", input);
    scanf("%s", subs);
    /* your code */
    printf("%s\n", output);
    return 0;
}

Input

The first line is the input string, and the second line is the substring to be deleted.

Output

A new string after deletion.

Sample Input  Download

Sample Output  Download

Tags




Discuss




10418 - Problem5   

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,4,0,0,9,0,0,33] is an eight-dimensional vector, which can be represented as
5:9 2:4 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.

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 order of the dimensions is arbitrary.

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