Codeforces Round 744 (Div. 3)


A. Casimir's String Solitaire
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
ABACAB
ABBA
AC
ABC
CABCBB
BCBCBCBCBCBCBCBC
Output
NO
YES
NO
NO
YES
YES
----------------------------------------------------------------------------------------------------
B. Shifting Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
8
2 3 1
*.*
...
4 9 2
*.*.*...*
.*.*...*.
..*.*.*..
.....*...
4 4 1
*.*.
****
.**.
....
5 5 1
.....
*...*
.*.*.
..*.*
...*.
5 5 2
.....
*...*
.*.*.
..*.*
...*.
4 7 1
*.....*
.....*.
..*.*..
...*...
3 3 1
***
***
***
3 5 1
*...*
.***.
.**..
Output
NO
YES
YES
YES
NO
NO
NO
NO
----------------------------------------------------------------------------------------------------
D. Productive Meeting
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2
2 3
3
1 2 3
4
1 2 3 4
3
0 0 2
2
6 2
3
0 0 2
5
8 2 0 1 1
5
0 1 0 0 6
Output
2
1 2
1 2
3
1 3
2 3
2 3
5
1 3
2 4
2 4
3 4
3 4
0
2
1 2
1 2
0
4
1 2
1 5
1 4
1 2
1
5 2
----------------------------------------------------------------------------------------------------
E1. Permutation Minimization by Deque
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
3 1 2 4
3
3 2 1
3
3 1 2
2
1 2
2
2 1
Output
1 3 2 4 
1 2 3 
1 3 2 
1 2 
1 2 
----------------------------------------------------------------------------------------------------
E2. Array Optimization by Deque
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
4
3 7 5 5
3
3 2 1
3
3 1 2
4
-1 2 2 -1
4
4 5 1 3
5
1 3 1 3 2
Output
2
0
1
0
1
2
----------------------------------------------------------------------------------------------------
F. Array Stabilization (AND version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 1
0 1
3 2
0 1 0
5 2
1 1 0 1 0
4 2
0 1 0 1
1 1
0
Output
1
1
3
-1
0
----------------------------------------------------------------------------------------------------
G. Minimal Coverage
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2
1 3
3
1 2 3
4
6 2 3 9
4
6 8 4 5
7
1 2 4 6 7 7 3
8
8 6 5 1 2 2 3 6
Output
3
3
9
9
7
8
----------------------------------------------------------------------------------------------------
