Codeforces Round 604 (Div. 1)


A. Beautiful Regional Contest
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
12
5 4 4 3 2 2 1 1 1 1 1 1
4
4 3 2 1
1
1000000
20
20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
32
64 64 63 58 58 58 58 58 37 37 37 37 34 34 28 28 28 28 28 28 24 24 19 17 17 17 17 16 16 16 16 11
Output
1 2 3
0 0 0
0 0 0
2 5 3
2 6 6
----------------------------------------------------------------------------------------------------
B. Beautiful Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 2 1
Output
YES
0 1 0 1 2 3 2
Input
1 2 3 4
Output
NO
Input
2 2 2 3
Output
NO
----------------------------------------------------------------------------------------------------
C. Beautiful Mirrors with queries
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2
50 50
2
2
Output
4
6
Input
5 5
10 20 30 40 50
2
3
4
5
3
Output
117
665496274
332748143
831870317
499122211
----------------------------------------------------------------------------------------------------
D1. Beautiful Bracket Sequence (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
??
Output
1
Input
(?(?))
Output
9
----------------------------------------------------------------------------------------------------
D2. Beautiful Bracket Sequence (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
??
Output
1
Input
(?(?))
Output
9
----------------------------------------------------------------------------------------------------
E. Beautiful League
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1
1 2
Output
010
001
100
Input
4 2
1 2
1 3
Output
0110
0001
0100
1010
----------------------------------------------------------------------------------------------------
F. Beautiful Fibonacci Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 1 1
Output
2 1
Input
5 1 2
Output
19 5
----------------------------------------------------------------------------------------------------
