Educational Codeforces Round 114 (Rated for Div. 2)


A. Regular Bracket Sequences
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1
3
Output
()()()
((()))
(()())
()
((()))
(())()
()(())
----------------------------------------------------------------------------------------------------
B. Combinatorics Homework
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2 1 0
1 1 1 1
1 2 3 2
Output
YES
NO
YES
----------------------------------------------------------------------------------------------------
C. Slay the Dragon
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

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

Examples
Input
2 2 7
1 1 1
1 2 1
2 1 1
1 1 0
1 2 -1
2 1 -1
1 1 -1
Output
3
1
0
1
2
3
6
----------------------------------------------------------------------------------------------------
F. Occurrences
time limit per test: 7 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 4 3
2 1 2
1 3
Output
5
Input
2 4 3
2 1 2
3 3 2 1
Output
0
Input
1 42 1337
2 13 31
Output
721234447
----------------------------------------------------------------------------------------------------
