Bubble Cup 8 - Finals [Online Mirror]


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

Examples
Input
10 8
3
1 2 1
2
7 3
5 4
Output
4
----------------------------------------------------------------------------------------------------
B. Bribes
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 0
2 3 0
5 1 1
3 4 1
5
5 4 5 2 2
Output
4
----------------------------------------------------------------------------------------------------
C. Party
time limit per test: 2 seconds
memory limit per test: 4 megabytes
input: standard input
output: standard output

Examples
Input
4
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
5 8 7 1
6 9 81 3
55 78 1 6
1 1 1 1
Output
167
----------------------------------------------------------------------------------------------------
D. Tablecity
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
В этой задаче нет примеров ввода-вывода.
This problem doesn't have sample input and output.
Output
Смотрите замечание ниже.
See the note below.
----------------------------------------------------------------------------------------------------
E. Spectator Riots
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1 1
1 1 1
1 2 1
Output
2 2
2 1
1 0
----------------------------------------------------------------------------------------------------
F. Bulbo
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 4
2 7
9 16
8 10
9 17
1 6
Output
8
----------------------------------------------------------------------------------------------------
G. Run for beer
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 10
0 1 1
1 2 5
2 7 6
0 3 2
3 7 3
0 4 0
4 5 0
5 7 2
0 6 0
6 7 7
Output
32
3
0 3 7
----------------------------------------------------------------------------------------------------
H. Bots
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
Output
19
----------------------------------------------------------------------------------------------------
I. Robots protection
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
17 10
1 1 3 2 4
1 3 10 3 7
1 2 6 8 2
1 3 9 4 2
2 4 4
1 4 15 10 6
2 7 7
2 9 4
2 12 2
2 13 8
Output
2
2
2
0
1
----------------------------------------------------------------------------------------------------
