Abbyy Cup 2.0 - Final (unofficial)


A1. Beaver's Calculator 1.0
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1 1 1 10
2 3 1 1 10
Output
0
1 1
2 1
3 2
4 2
Input
2
3 10 2 3 1000
3 100 1 999 1000
Output
2
10 1
23 1
49 1
100 2
99 2
98 2
----------------------------------------------------------------------------------------------------
A2. Beaver's Calculator 1.0
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1 1 1 10
2 3 1 1 10
Output
0
1 1
2 1
3 2
4 2
Input
2
3 10 2 3 1000
3 100 1 999 1000
Output
2
10 1
23 1
49 1
100 2
99 2
98 2
----------------------------------------------------------------------------------------------------
A3. Beaver's Calculator 1.0
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 1 1 1 10
2 3 1 1 10
Output
0
1 1
2 1
3 2
4 2
Input
2
3 10 2 3 1000
3 100 1 999 1000
Output
2
10 1
23 1
49 1
100 2
99 2
98 2
----------------------------------------------------------------------------------------------------
B1. Military Trainings
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1
1
Output
5
Input
5
2
2
2
2
2
Output
10
----------------------------------------------------------------------------------------------------
B2. Military Trainings
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1
1
Output
5
Input
5
2
2
2
2
2
Output
10
----------------------------------------------------------------------------------------------------
B3. Military Trainings
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2
1
1
Output
5
Input
5
2
2
2
2
2
Output
10
----------------------------------------------------------------------------------------------------
C1. Game with Two Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 a
2 1 a
1 2 b
2 1 b
2 3 a
Output
1
3
3
4
7
----------------------------------------------------------------------------------------------------
C2. Game with Two Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 a
2 1 a
1 2 b
2 1 b
2 3 a
Output
1
3
3
4
7
----------------------------------------------------------------------------------------------------
C3. Game with Two Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 a
2 1 a
1 2 b
2 1 b
2 3 a
Output
1
3
3
4
7
----------------------------------------------------------------------------------------------------
D1. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D10. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D2. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D3. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D4. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D5. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D6. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D7. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D8. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
D9. The Beaver's Problem - 3
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

No test samples are available for this problem
----------------------------------------------------------------------------------------------------
