Bubble Cup 13 - Finals [Online Mirror, unrated, Div. 2]


A. Wakanda Forever
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
35 19 20
76 14 75
23 43 78
14 76 98
Output
3
4
1
2
Input
4
2 5 8
7 1 12
4 6 7
8 4 5
Output
-1
----------------------------------------------------------------------------------------------------
B. Valuable Paper
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
1 2 1
2 3 2
3 3 3
2 1 4
2 2 5
Output
4
----------------------------------------------------------------------------------------------------
C. Dušan's Railway
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 3
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
Output
8
3 7
3 5
3 6
3 1
7 9
7 10
7 4
7 5
----------------------------------------------------------------------------------------------------
D. Does anyone else hate the wind?
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
5 2 15
M S S
S S S
S S P
S W N N N N N N N N N N N N N
2 1 0
1 2 0
Output
-1
Input
3 3
5 2 15
M S S
S S S
S S P
S E N N N N N N N N N N N N N
2 1 0
1 2 0
Output
2
Input
5 5
4 1 15
M S S S S
S S S S L
S S S L L
S S S S S
S S S S P
C C C C S S E E C C C C C C C
0 1 4
Output
8
----------------------------------------------------------------------------------------------------
E. 5G Antenna Towers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 10 3
4 2 2 3 2 3 3 2 3
3 3.5 2 4.5 2 4.5 3
4 7 8 7.5 8.5 8 8 7.5 9
5
2 3.5 0.5
3.3 2 0.4
5 2.5 0.5
7.5 8.5 0.5
3 7 0.5
Output
1.000000 1 0 
1.500000 2 0 1 
0.500000 1 1 
0.250000 1 2 
0.000000 0 
----------------------------------------------------------------------------------------------------
F. Coins
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 2
2 2
Output
1
Input
6 2
2 3
4 1
Output
1
Input
3 2
1 1
2 2
Output
-1
----------------------------------------------------------------------------------------------------
G. Years
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 5
2 4
5 6
Output
2 2
Input
4
3 4
4 5
4 6
8 10
Output
4 2
----------------------------------------------------------------------------------------------------
H. Lookup Tables
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2
0 2 1
3 3 3
Output
possible
1
3
1
3
Input
2 4
4 5 3
6 7 2
0 3 0
12 13 1
Output
possible
3
3
2
2
0
3
0
1
Input
2 3
4 4 3
5 6 2
12 14 1
Output
impossible
----------------------------------------------------------------------------------------------------
I. Bubble Cup hypothesis
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 4
Output
2
4
----------------------------------------------------------------------------------------------------
J. Lonely Numbers
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 5 10
Output
1
3
3
----------------------------------------------------------------------------------------------------
K. Light switches
time limit per test: 3 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
4 3 4
2 1 2
2 2 3
1 2
1 1
2 1 3
3 1 2 3
3 1 2 4
Output
2
2
3
-1
----------------------------------------------------------------------------------------------------
L. Milutin's Plums
time limit per test: 1 second
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
5 5
13 15 10 9 15
15 17 12 11 17
10 12 7 6 12
17 19 14 13 19
16 18 13 12 18
Output
----------------------------------------------------------------------------------------------------
M. Ancient Language
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2
b
b
bbac
0
a
aca
acba
1
ab
c
ccb
Output
acb
----------------------------------------------------------------------------------------------------
N. BubbleSquare Tokens
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 1
1 2
Output
1
1 
1 2 0
Input
3 3
1 2
1 3
2 3
Output
0
1 2 0
2 3 1
1 3 2
----------------------------------------------------------------------------------------------------
