Educational Codeforces Round 137 (Rated for Div. 2)


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

Examples
Input
2
8
0 1 2 4 5 6 8 9
1
8
Output
6
216
----------------------------------------------------------------------------------------------------
B. Permutation Value
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
5
6
Output
1 4 3 5 2
4 1 6 2 5 3
----------------------------------------------------------------------------------------------------
C. Save the Magazines
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
01110
10 5 8 9 6
6
011011
20 10 9 30 20 19
4
0000
100 100 100 100
4
0111
5 4 5 1
Output
27
80
0
14
----------------------------------------------------------------------------------------------------
D. Problem with Random Tests
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
11010
Output
11111
Input
7
1110010
Output
1111110
Input
4
0000
Output
0
----------------------------------------------------------------------------------------------------
E. FTL
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 10
4 9
16 1
Output
20
Input
10 1
5000 100000
25 9
Output
25
----------------------------------------------------------------------------------------------------
F. Intersection and Union
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 5
4 8
2 2
1 9
Output
162
Input
4
1 9
3 5
4 8
2 2
Output
102
----------------------------------------------------------------------------------------------------
G. Antifibonacci Cut
time limit per test: 12 seconds
memory limit per test: 4 megabytes
input: standard input
output: standard output

Examples
Input
1
10110101
Output
3
Input
3
1111
1
0
Output
2
3
3
Input
6
10110101
100100001110
0000001100010001
1111
1001010100101010101001
000100000010101111
Output
3
561
1466229
9887505
972227653
52128355
----------------------------------------------------------------------------------------------------
