Bubble Cup 12 - Finals [Online Mirror, unrated, Div. 1]


A. BubbleReactor
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
0 1
0 3
0 4
0 9
1 2
2 3
2 7
4 5
4 6
7 8
Output
51
----------------------------------------------------------------------------------------------------
B. Guarding warehouses
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4 1 1 1 3 3 3 3 1
4 4 3 6 2 6 0 4 0
6 -5 3 -4 4 -3 4 -2 3 -3 2 -4 2
3 0 -1 1 -3 -1 -3
4 1 -4 1 -6 -1 -6 -1 -4
Output
13.333333333333
----------------------------------------------------------------------------------------------------
C. Jumping Transformers
time limit per test: 4 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
3 3 5
0 1 1 0 7
1 1 1 0 10
1 1 1 1 2
1 1 1 2 2
0 1 1 2 3
Output
9
----------------------------------------------------------------------------------------------------
D. Xor Spanning Tree
time limit per test: 2 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
6 6
4 1 5
5 2 1
6 3 2
1 2 6
1 3 3
2 3 4
Output
1 1
----------------------------------------------------------------------------------------------------
E. Product Tuples
time limit per test: 8 seconds
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
5
2
1 2 3 4 5
3
1 6 1 1
1 6 5 2
2 6 2 3 1
Output
85
127
63
----------------------------------------------------------------------------------------------------
F. Workout plan
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 10000
10000 30000 30000 40000 20000
20000
5 2 8 3 6
Output
5
Input
5 10000
10000 40000 30000 30000 20000
10000
5 2 8 3 6
Output
-1
----------------------------------------------------------------------------------------------------
G. Alpha planetary system
time limit per test: 1 second
memory limit per test: 128 megabytes
input: standard input
output: standard output

Examples
Input
10
15
XXXXYYYZZZ
0 4
0 5
0 6
4 1
4 8
1 7
1 9
7 2
7 5
5 3
6 2
6 9
8 2
8 3
9 3
Output
0 4 2
0 5 2
0 6 2
4 1 1
4 8 1
1 7 2
1 9 3
7 2 2
7 5 1
5 3 1
6 2 1
6 9 1
8 2 3
8 3 1
9 3 1
----------------------------------------------------------------------------------------------------
H. Function Composition
time limit per test: 0.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
2 3 1 5 6 4 2 10 7 7
5
10 1
5 7
10 6
1 1
10 8
Output
3
0
1
1
0
----------------------------------------------------------------------------------------------------
I. The Light Square
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
11
11
00
01
11
Output
-1
Input
2
10
00
00
00
10
Output
1
row 0
Input
3
110
011
100
100
011
100
100
Output
3
row 0
col 0
col 1
----------------------------------------------------------------------------------------------------
