AIM Tech Round 5 (rated, Div. 1 + Div. 2)


A. Find Square
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 6
WWBBBW
WWBBBW
WWBBBW
WWWWWW
WWWWWW
Output
2 4
Input
3 3
WWW
BWW
WWW
Output
2 1
----------------------------------------------------------------------------------------------------
B. Unnatural Conditions
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 5
Output
6 
7
Input
8 16
Output
35 
53
----------------------------------------------------------------------------------------------------
C. Rectangles
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
0 0 1 1
1 1 2 2
3 0 4 1
Output
1 1
Input
3
0 0 1 1
0 1 1 2
1 0 2 1
Output
1 1
Input
4
0 0 5 5
0 0 4 4
1 1 4 4
1 1 4 4
Output
1 1
Input
5
0 0 10 8
1 2 6 7
2 3 5 6
3 4 4 5
8 1 9 2
Output
3 4
----------------------------------------------------------------------------------------------------
D. Order book
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
ADD 1
ACCEPT 1
ADD 2
ACCEPT 2
ADD 3
ACCEPT 3
Output
8
Input
4
ADD 1
ADD 2
ADD 3
ACCEPT 2
Output
2
Input
7
ADD 1
ADD 2
ADD 3
ADD 4
ADD 5
ACCEPT 3
ACCEPT 5
Output
0
----------------------------------------------------------------------------------------------------
E. Restore Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 1 0
Output
YES
1 3 5 2
Input
2
4 4
Output
NO
----------------------------------------------------------------------------------------------------
F. Make Symmetrical
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
12
1 1 6
1 6 1
1 5 5
1 2 3
3 4 4
1 3 2
3 7 7
2 2 3
2 6 1
3 8 8
2 5 5
3 1 1
Output
1
0
2
2
Input
6
1 1 2
3 1 1
1 1 1
3 2 2
2 1 1
3 2 4
Output
1
1
0
----------------------------------------------------------------------------------------------------
G. Guess the number
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
 
2
0
-1
Output
2 2 3
2 20 30
3 5 7 9
----------------------------------------------------------------------------------------------------
H. Make Square
time limit per test: 7 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
10 10
34 37 28 16 44 36 43 50 22 13
1 3
4 8
6 10
9 10
3 10
8 9
5 6
1 4
1 7
2 6
Output
2
0
1
3
0
1
1
1
0
0
----------------------------------------------------------------------------------------------------
