VK Cup 2019-2020 - Final Round (Engine)


A. Identify the Operations
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
5 3
1 2 3 4 5
3 2 5
4 3
4 3 2 1
4 3 1
7 4
1 4 7 3 6 2 5
3 2 4 5
Output
2
0
4
----------------------------------------------------------------------------------------------------
B. Graph Transpositions
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2
2 3
3 4
4 1
Output
2
Input
4 3
2 1
2 3
4 3
Output
10
----------------------------------------------------------------------------------------------------
C. Sum
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 3
2 5 10
3 1 2 3
2 1 20
Output
26
----------------------------------------------------------------------------------------------------
D. Black, White and Grey Tree
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 1
1 2
4
1 2 1 2
1 2
2 3
3 4
5
1 1 0 1 2
1 2
2 3
3 4
3 5
8
1 2 1 2 2 2 1 2
1 3
2 3
3 4
4 5
5 6
5 7
5 8
Output
1
3
2
3
----------------------------------------------------------------------------------------------------
E. Differentiating Games
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2 3
1 2
2 3
Lose
Correct
Win
Correct
Draw
Correct
Output
6
+ 2 2
- 1 2
+ 2 3
- 2 2
+ 3 1
+ 2 2
? 0
! 1
? 1 2
! 3
? 5 1 3 1 3 1
! 2
----------------------------------------------------------------------------------------------------
F. Matching
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 3
0 0
1 1
2 4
1 2
2 3
1 3
4 3
0 1
1 0
2 0
3 1
1 2
2 3
3 4
4 4
0 1
1 0
2 0
3 1
1 2
2 3
3 4
1 4
6 7
-2 1
-2 -1
-1 0
1 0
2 1
2 -1
1 2
1 3
2 3
3 4
4 5
4 6
5 6
Output
0
1
0
1
----------------------------------------------------------------------------------------------------
