Educational Codeforces Round 123 (Rated for Div. 2)


A. Doors and Keys
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
rgbBRG
RgbrBG
bBrRgG
rgRGBb
Output
YES
NO
YES
NO
----------------------------------------------------------------------------------------------------
B. Anti-Fibonacci Permutation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
3
Output
4 1 3 2
1 2 4 3
3 4 1 2
2 4 1 3
3 2 1
1 3 2
3 1 2
----------------------------------------------------------------------------------------------------
C. Increase Subarray Sums
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 2
4 1 3 2
3 5
-2 -7 -1
10 2
-6 -1 -2 4 -6 -1 -4 4 -5 -4
Output
10 12 14 16 18
0 4 4 5
4 6 6 7 7 7 7 8 8 8 8
----------------------------------------------------------------------------------------------------
D. Cross Coloring
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 1 3 2
1 1
1 1
2 2 2 3
2 1
1 1
2 2
Output
3
4
----------------------------------------------------------------------------------------------------
E. Expand the Path
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
RD
5
DRDRDRDR
3
D
Output
13
9
3
----------------------------------------------------------------------------------------------------
F. Basis
time limit per test: 6 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
Output
2
Input
4 10
Output
12
Input
13 37
Output
27643508
Input
1337 42
Output
211887828
Input
198756 123456
Output
159489391
Input
123456 198756
Output
460526614
----------------------------------------------------------------------------------------------------
