Codeforces Round 545 (Div. 2)


A. Sushi for Two
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2 2 2 1 1 2 2
Output
4
Input
6
1 2 1 2 1 2
Output
2
Input
9
2 2 1 1 1 2 2 2 2
Output
6
----------------------------------------------------------------------------------------------------
B. Circus
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
0011
0101
Output
1 4
Input
6
000000
111111
Output
-1
Input
4
0011
1100
Output
4 3
Input
8
00100101
01111100
Output
1 2 3 6
----------------------------------------------------------------------------------------------------
C. Skyscrapers
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 3
1 2 1
2 1 2
Output
2 2 2 
2 2 2 
Input
2 2
1 2
3 4
Output
2 3 
3 2 
----------------------------------------------------------------------------------------------------
D. Camp Schedule
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
101101
110
Output
110110
Input
10010110
100011
Output
01100011
Input
10
11100
Output
01
----------------------------------------------------------------------------------------------------
E. Museums Tour
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 5 3
3 1
1 2
2 4
4 1
2 3
011
110
111
001
Output
3
Input
3 3 7
1 2
1 3
2 3
1111111
0000000
0111111
Output
2
----------------------------------------------------------------------------------------------------
F. Cooperative Game
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 05 12346789
3 246789 135 0
3 246789 0 135
3 246789 0 135
2 135 0246789
1 0123456789
Output
next 0 5
next 0 1 3
next 2 3 0 1 4 5 6 7 8 9
next 9 8 7 6 5 4 3 2 1 0
next 0 1 3 5
next 1 3 5
done
----------------------------------------------------------------------------------------------------
