Educational Codeforces Round 119 (Rated for Div. 2)


A. Equal or Not Equal
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
EEE
EN
ENNEENE
NENN
Output
YES
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. Triangles on a Rectangle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 8
2 1 2
3 2 3 4
3 1 4 6
2 4 5
10 7
2 3 9
2 1 7
3 1 3 4
3 4 5 6
11 5
3 1 6 8
3 3 6 8
3 1 3 4
2 2 4
Output
25
42
35
----------------------------------------------------------------------------------------------------
C. BA-String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 4 3
a*
4 1 3
a**a
6 3 20
**a***
Output
abb
abba
babbbbbbbbb
----------------------------------------------------------------------------------------------------
D. Exact Change
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
1337
3
10 8 10
5
1 2 3 4 5
3
7 77 777
Output
446
4
3
260
----------------------------------------------------------------------------------------------------
E. Replace the Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
1 3
1 1
2 1 2
1 2
1 1
1 2
2 1 3
Output
3 2 2 3 2 
Input
4
1 1
1 2
1 1
2 2 2
Output
1 2 1 
Input
8
2 1 4
1 1
1 4
1 2
2 2 4
2 4 3
1 2
2 2 7
Output
1 3 3 7 
----------------------------------------------------------------------------------------------------
F. Bipartite Array
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3
1 2 3
6
1 3 2 6 5 4
4
4 1 3 2
8
3 2 1 6 7 8 5 4
Output
YES
1 2 3
NO
YES
-4 -1 -3 -2
YES
-3 -2 1 6 7 -8 -5 -4
----------------------------------------------------------------------------------------------------
G. Subsequences Galore
time limit per test: 10 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
3
a
b
c
Output
92
Input
2
aa
a
Output
21
Input
2
a
a
Output
10
Input
2
abcd
aabb
Output
124
Input
3
ddd
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaabbbbbbbbbbbcccccccccccciiiiiiiiiiiiiiiiiiiiiiooooooooooqqqqqqqqqqqqqqqqqqvvvvvzzzzzzzzzzzz
Output
15706243380
----------------------------------------------------------------------------------------------------
