Codeforces Round 771 (Div. 2)


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

Examples
Input
4
1
1
3
2 1 3
4
1 4 2 3
5
1 2 3 4 5
Output
1 
1 2 3 
1 2 4 3 
1 2 3 4 5 
----------------------------------------------------------------------------------------------------
B. Odd Swap Sort
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
1 6 31 14
2
4 2
5
2 9 6 7 10
3
6 6 6
Output
Yes
No
No
Yes
----------------------------------------------------------------------------------------------------
C. Inversion Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3
1 2 3
5
2 1 4 3 5
6
6 1 4 2 5 3
1
1
6
3 2 1 6 5 4
5
3 1 5 2 4
Output
3
3
1
1
2
1
----------------------------------------------------------------------------------------------------
D. Big Brush
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
5 5 3 3
1 1 5 3
2 2 5 4
2 2 4 4
Output
6
1 3 3
3 3 4
2 2 5
1 1 5
2 1 1
3 1 2
Input
3 4
1 1 1 1
2 2 3 1
2 2 1 1
Output
-1
----------------------------------------------------------------------------------------------------
E. Colorful Operations
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 8
Color 2 4 2
Add 2 2
Query 3
Color 4 5 3
Color 2 2 3
Add 3 3
Query 2
Query 5
Output
2
5
3
Input
2 7
Add 1 7
Query 1
Add 2 4
Query 2
Color 1 1 1
Add 1 1
Query 2
Output
7
7
8
----------------------------------------------------------------------------------------------------
F. Two Posters
time limit per test: 2 seconds
memory limit per test: 1024 megabytes
input: standard input
output: standard output

Examples
Input
6
2 2 3 5 4 5
Output
18
Input
1
1
Output
1
----------------------------------------------------------------------------------------------------
