| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 11714 | Ponds |
|
| 11717 | Max Block Sum |
|
| 11718 | Left Right |
|
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
(6 points)
Given a sequence of Left and Right operations, calculate the answer.
'Lab' means Left(a, b), which will choose the left element, and the answer is a.
'Rcd' means Right(c, d), which will choose the right element, and the answer is d.
For a longer sequence such as 'RLxyRRefLmn', it means
Right(Left(x, y), Right(Right(e, f), Left(m, n)))
and the answer is m.
Input
A sequence of Left and Right operations.
Operands are lowercase letters from 'a' to 'z'.
'L' denotes Left and 'R' denotes Right.
There is a symbol '=' at the end of input.
No blanks between elements.
The length of input (including '=') is less than 40.
Output
Print the answer.
Remeber there have to be a newline character in the end.