Educational Codeforces Round 134 (Rated for Div. 2)


A. Image
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
rb
br
cc
wb
aa
aa
ab
cd
yy
xx
Output
1
2
0
3
1
----------------------------------------------------------------------------------------------------
B. Deadly Laser
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 3 1 3 0
2 3 1 3 1
5 5 3 4 1
Output
3
-1
8
----------------------------------------------------------------------------------------------------
C. Min-Max Array Transformation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
2 3 5
7 11 13
1
1000
5000
4
1 2 3 4
1 2 3 4
4
10 20 30 40
22 33 33 55
Output
5 4 2
11 10 8
4000
4000
0 0 0 0
0 0 0 0
12 2 3 15
23 13 3 15
----------------------------------------------------------------------------------------------------
D. Maximum AND
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5
1 0 0 3 3
2 3 2 1 0
3
1 1 1
0 0 3
8
0 1 2 3 4 5 6 7
7 6 5 4 3 2 1 0
Output
2
0
7
----------------------------------------------------------------------------------------------------
E. Prefix Function Queries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aba
6
caba
aba
bababa
aaaa
b
forces
Output
0 1 2 3 
1 2 3 
2 3 4 5 6 7 
1 1 1 1 
2 
0 0 0 0 0 0 
Input
aacba
4
aaca
cbbb
aab
ccaca
Output
2 2 3 1 
0 0 0 0 
2 2 0 
0 0 1 0 1 
----------------------------------------------------------------------------------------------------
F. Matching Reduction
time limit per test: 8 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4 4 4
2 2
1 3
2 1
3 4
1
2
1
2
Output
1
-4
3
===
2
1 2
===
1
2
2
===
1
2
----------------------------------------------------------------------------------------------------
