| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10398 | Rock-paper-scissors |
|
| 10399 | Line Reader |
|
| 10400 | plant trees |
|
| 10401 | palindrome |
|
| 10402 | Sparse Vectors 2 |
|
Description
Rock-paper-scissors is a two player game. A game can have many rounds.
Hint:
#includeint main() { char name1[10]; char name2[10]; char ges1, ges2; scanf("%s %s", name1, name2); int i; int N; /* declare any other variable if required */ scanf("%d", &N); // N rounds in the game getchar(); for(i=0; i
Input
The first line contains two strings, which are the names of two players. The length of the names is less than ten characters.The second line contains a number N, indicating how many rounds in this game, 1<=N<=10.Next, there will be N lines. Each line has two characters, separated by a space.Each character can be one of ‘R’, ’S’, or ‘P’, representing Rock, Scissors, and Paper, respectively.The first character is the sign shown by the first player; and the second character is the sign shown by the second player.
Output
Print the name of the winner in the game.
If no one wins, print "draw".Notice that there will be a newline in the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
“Line Reader” is a program that shows only one line of the input article (which is composed by many lines of strings).
Initially, it shows the first line of the article.
Users can control the Line Reader by four commands.
1. u : show the previous line of the current line. If the current line is the 15th line, Line Reader will show the 14th line.
2. d : show the next line of the current line. If the current line is the 15th line, Line Reader will show the 16th line.
3. U : show the 10th line previous to the current line. If the current line is the 15th line, Line Reader will show the 5th line.
4. D : show the 10th line next to the current line. If the current line is the 15th line, Line Reader will show the 25th line.If the line number is less than 1, the Line Reader will show the first line.
If the line number is larger than the total number of lines in the article, the Line Reader will show the last line.
If the line number is smaller than 0 in the article, the Line Reader will show the first line.
For example,
if the current line is the 15th line, and the total number of lines in the article is 20,
after the command D, the Line Reader will show the 20th line.
HINT:
#includeint main(){ int n, m; int i, now; char arr[20][31]; char *str; char ins; scanf( "%d", &n ); for( i = 0 ; i < n ; i++ ){ scanf( "%s", arr[i] ); } //Insert your code here to get commands and execute them return 0; }
Input
N lines of strings
String 1
String 2
String 3
...
String N
M lines of commands
Command 1
Command 2
Command 3
...
Command M
where 1 ≤ N,M ≤ 20
The length of string is less than or equal to 30 and the string doesn't include any whitespace character.
Output
Show the string after applying command 1
Show the string after applying command 2
Show the string after applying command 3
...
Show the string after applying command M
Each end of strings has a newline symbol
Sample Input Download
Sample Output Download
Tags
Discuss
Description
There is a road, which has N blocks.
Hint:
#includeint main() { int N, typeNum; int i; char blocks[100]; char tree; int d; /* declare any other variable if required. */ scanf("%d", &N); // read number of blocks, N
scanf("%d", &typeNum); // read number of trees' types /* initialize the blocks */ /* add your code here */ getchar(); // read '\n' for(i=0; iblocks[i]);
printf("\n"); return 0; }
Input
(Number of blocks N.)
Output
The final appearance of the road.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
In this problem:
1. Given a string consisting only of digit '1' to '9' and each digit character appears at most once,
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.
In palindrom, each digit characters in string must appear twice.
For example, the input string is 321.
And all possible palindroms made by the combination of those three digits are
123321
132231
213312
231132
312213
321123
The smallest value of above numbers is 123321.
Input
The input is a string which consists only of digit characters '1' to '9'.
1 ≤ string length L ≤ 9
Output
The smallest value of palindrome.
Note : You need to print a newline at the end of output
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given two vectors, compute the sum of the corresponding elements and find the largest component. For example, the sum of [1,2,-3] and [4,5,6] is [5, 7, 3], and the largest component is 7.
We may represent a high-dimensional sparse vector using the following format:
dim1:value1 dim2:value2 dim3:value3 … 0:0
where 0:0 denotes the end of the vector.
Here is 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.
Input
The input has two lines. Each line contains a vector of integer values represented in the sparse format. The dimension of the vector is no greater than 2 to the 31st power. The usage of memory is limited to 32 MB.
Output
The output is the largest component of the sum of the two input vectors. The answer should be printed in one line with a newline character at the end.
There is a newline in the end.