| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11388 | Evaluate expression |
|
| 11624 | Bit reverse |
|
| 11690 | pB - Transpose |
|
| 11714 | Ponds |
|
| 11717 | Max Block Sum |
|
| 11929 | Reorder (absolute value) |
|
| 11966 | Parentheses Matching |
|
Description
Given a prefix Boolean expression, which only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. Also given the values of ‘A’, ‘B’, ‘C’, and ‘D’. Please evaluate the value of the prefix Boolean expression.
For example, if the expression is "|&AC|AB" and, A, B, C, D are 0, 1, 0, 1 then the result will be 1.
Input
The input contains 2 lines.
The first line contains a prefix Boolean expression. It only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. The length of the prefix expression is shorter than 30.
The second line contains 4 values of 1 or 0, representing the values of A, B, C, D respectively. Each is separated by a space.
Output
Print out the value of the prefix Boolean expression. There should be no trailing newline character at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Nymphia is reading an eight-digit binary number consisting of 0s and 1s through a mirror. Because right and left are reversed in the mirror, Nymphia gets a wrong number when she directly converts the binary number to the corresponding decimal number according to the order she saw in the mirror. Can you help Nymphia correct this wrong number?
Input
Only a number N, 0<=N<=2^8
Output
Please output a decimal number with correct interpretation, and be sure to put ‘\n’ at the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Writer: jjjjj19980806 Description: pclightyear Difficulty: ★☆☆☆☆
jjjjj doesn't like long description.
Given an m ✕ n matrix A, please calculate the transpose of A.
Note: The is a partial judge problem. We have already handled the input and output for you. All you have to do is to implement the function "Transpose".
Input
The first line contains two integers m, n, representing the dimension of A.
The next m lines contain n integers aij, representing the indices of A.
It is guaranteed that :
- 1 ≤ m, n ≤ 500
We have already handled the input for you.
Output
Please output the transpose of A.
We have already handled the output for you.
Sample Input Download
Sample Output Download
Partial Judge Code
11690.cPartial Judge Header
11690.hTags
Discuss
Description
HT Chen gives you a map sized m ✕ n consists of only two symbols '~' and'.', representing water and land, respectively. He wonders how many ponds (consecutive position of water) are there on the map. He has a thought that if he can write a recursive function, the problem may be very easy to solve!
Input
The first line contains two integer m, n, representing the size of the map Frank gives to you.
The next m lines contain n characters, either '~' or '.', representing the status of position aij.
It is guaranteed that :
- 1 ≤ m, n ≤ 1000
Output
Please output the number of ponds on the map.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
(7 points)
Given an n-by-n square matrix A, divide it into 2-by-2 non-overlapping blocks.
Compute the sum of each 2-by-2 block and find the maximum block sum.
For example, if the square matrix A is
1 2 3 4
5 6 7 8
9 8 7 6
5 4 3 2
There are four non-overlapping 2-by-2 blocks, which are
1 2
5 6
3 4
7 8
9 8
5 4
7 6
3 2
The maximum block sum is 26, yielded by the block
9 8
5 4
#include <stdio.h>
int main(){
int A[500][500];
int ans = 0;
int n = 0;
scanf("%d", &n);
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
scanf("%d", &A[i][j]);
}
}
/* Your Code: */
printf("%d\n", ans);
return 0;
}
Input
The first line contains an integer n, representing the size of A. It is guaranteed that 1 <= n <= 500, and n is always a multiple of 2.
The next n lines represent the n rows of A. Each row contains n integers.
The code for reading the input and printing the output is given.
Output
Print the maximum block sum of A.
Remember printing '\n' in the end.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Given four integer numbers, please rearrange the value of them in increasing order according to their absolute value.
Input
The input has four integer numbers num1, num2, num3, and num4.
Output
Print num1, num2, num3, num4 sequentially, and the output should be in increasing order according to their absolute value.
If the absolute value of numbers are the same, put the negative number in front.
Sample Input Download
Sample Output Download
Partial Judge Code
11929.cPartial Judge Header
11929.hTags
Discuss
Description
A string is said to be valid if it matches one of the following rules:
(1) The string is an empty string.
(2) If a string S is valid, then {S}, [S], (S) and <S> are valid.
(3) If strings S1 and S2 are both valid, then S1S2 is valid.
Given a string consisting of parentheses, determine if it is a valid string.
Input
The first line of the input contains an integer N (N ≤ 1000) denoting the number of test cases followed by. Each of the next N lines corresponds to a test case, which contains a string consisting of parentheses, and the maximum string length will be no more than 1000. Note that an empty string (a line which contains the newline character only) may be contained in the input and it should be considered as a valid string according to rule (1).
For case 1,2 : 1<N<100. 0<=length<100
For case 3,4 : 1<N<1000. 0<=length<1000
Output
For each test case, print “Case i:” and then “Yes” or “No” to indicate that the string is valid or not, separated by a space character. i is the test case number starting from 1.