Educational Codeforces Round 166 (Rated for Div. 2)


A. Verify Password
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
12ac
5
123wa
9
allllmost
5
ac123
6
011679
Output
YES
NO
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Increase/Decrease/Copy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
2
1 3
2
3 3
3 3 3
4
4 2 1 2
2 1 5 2 3
Output
3
1
8
----------------------------------------------------------------------------------------------------
C. Job Interview
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 0
2 1
1 2
0 2
4 5 5
5 4 1
1 2
2 1 5 4
5 2 3 1
3 1
4 3 3 4 1
5 5 4 5 2
Output
1 2 
5 6 9 
8 11 11 12 
13 13 13 12 15 
----------------------------------------------------------------------------------------------------
D. Invertible Bracket Sequences
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
(())
()
()()()
(()())(())
Output
1
0
3
13
----------------------------------------------------------------------------------------------------
E. Splittable Permutations
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 3
6 4 4
5 5 2
Output
30
Input
10 1
10
9
Output
1814400
Input
4 1
2
4
Output
8
----------------------------------------------------------------------------------------------------
F. Remove Bridges
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 2
12
4 10
5 12
12 11
3 6
9 6
1 6
12 7
11 6
2 11
10 9
10 8
8
1 2
2 3
2 4
3 5
3 6
4 7
4 8
5
1 2
2 3
3 4
4 5
Output
0 
7 3 1 0 0 0 0 0 0 0 0 
4 1 0 0 0 0 0 
0 0 0 0 
----------------------------------------------------------------------------------------------------
