| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 12080 | CS_2018_MID2-1 |
|
| 12081 | CS_2018_MID2-2 |
|
| 12082 | CS_2018_MID2-3 |
|
| 12083 | CS_2018_MID2-4 |
|
Description
Given an m ✕ n matrix A, please calculate the k-by-k max-pooling of A.
Both m and n are multiples of k.
The computation of k-by-k max-pooling is to find the maximum for each k-by-k block of A.
For example, if k is 2 and A is
1 2 3 4 5 6
6 5 4 3 2 1
9 8 7 6 5 4
4 5 6 7 8 9
, then the output should be
6 4 6
9 7 9
because they are the maximal values of the partitions:
1 2|3 4|5 6
6 5|4 3|2 1
---+---+---
9 8|7 6|5 4
4 5|6 7|8 9
Note: This 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 "max_pooling".
void max_pooling(int A[500][500], int H, int W, int k)
Input
The first line contains three integers m, n, and k, representing the dimensions m, n of matrix A and the size of the block.
The next m lines are elements of the matrix [Aij], i = 0...(m-1) and j = 0...(n-1)
It is guaranteed that 1 ≤ m, n ≤ 500 and k is either 2 or 3
Notice that if k = 2, m and n can be divided by 2, and so on.
We have already handled the input for you.
Output
Please print the result of k-by-k max-pooling.
We have already handled the output for you.
Sample Input Download
Sample Output Download
Partial Judge Code
12080.cPartial Judge Header
12080.hTags
Discuss
Description
Compute the numbers of islands on the map.
The character '~' means water. There are two types of islands, denoted as '#' and '@'.
Take the following map for example:

The number of #-typed islands is 3, and the number of @-typed islands is 2.
Note that two '#'s are considered connected only if they are horizontal or vertical neighbors. Diagonal neighbors are not considered connected. The rule is the same for '@'.
Input
The first line contains two integers m, n, representing the height and width of the map.
The next m lines contain n characters for the mth row of the map.
It is guaranteed that 1 ≤ m, n ≤ 1000
Output
Print the number of islands for '#' and the number of islands for '@'.
The two numbers are separated by a whitespace. Please include a newline character '\n' at the end of the output.
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You have to place N queens on a NxN chessboard in such a way that no queen threatens another one.
The rule is that each row and column of the board contains exactly 1 queen , and each diagonal contains no more than 1 queen.
Your mission is to compute how many possible ways to place N queens on that chessboard.
Input
An integer N which represent the size of chessboard and the number of queens
where 1<=N<=50.
Output
An integer which represent the number of possible distributions of N queens.
There is no need to add '\n' at the end of output
Sample Input Download
Sample Output Download
Tags
Discuss
Description
You want to stimulate shooting route in a room. You know the boundary of room, the start point of a shooting object, and the direction of shooting. When the object hitting the boundary, it would reflect with 45 degrees. Your mission is to show the route of the shooting object.
Input
The first line has three numbers, C, F and H, which respectively means the length of the ceiling, the length of the floor, and the height between the ceilings and floors.
The second line has a number S, which means the start point of shooting object. It's noted that the location below the ceiling is 1, and the location below that is 2, and so on.
- 1 ≤ C, F ≤ 20
- 2 ≤ H ≤ 20
- 1 ≤ S ≤ H
The third line has a character 'u' or 'd'. It corresponds to the initial direction of shooting.
- u: upper-right in 45 degree
- d: lower-right in 45 degree
There are only one case for each testcase
Output
Draw the map and the route of the shooting object.
The route of shooting object is marked as '*', which appears until the object is out of boundaries.
You need to use a (H+2)*(max{C, F, the horizontal length of the route of shooting}) array to print out the result
Remember there is '\n' in the end.