Codeforces Global Round 12


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

Examples
Input
3
11
antontrygub
15
bestcoordinator
19
trywatchinggurabruh
Output
bugyrtnotna
bestcoordinator
bruhtrywatchinggura
----------------------------------------------------------------------------------------------------
B. Balls of Steel
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2
0 0
3 3
1 1
3 3
6 7
8 8
6 9
4 1
0 0
0 1
0 2
0 3
Output
-1
1
-1
----------------------------------------------------------------------------------------------------
C1. Errich-Tac-Toe (Easy Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
.X.
XXX
.X.
6
XX.XXX
XXXXXX
XXX.XX
XXXXXX
XX.X.X
XXXXXX
5
XXX.X
.X..X
XXX.X
..X..
..X..
Output
.X.
XOX
.X.
XX.XXO
XOXXOX
OXX.XX
XOOXXO
XX.X.X
OXXOXX
XOX.X
.X..X
XXO.O
..X..
..X..
----------------------------------------------------------------------------------------------------
C2. Errich-Tac-Toe (Hard Version)
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
.O.
OOO
.O.
6
XXXOOO
XXXOOO
XX..OO
OO..XX
OOOXXX
OOOXXX
5
.OOO.
OXXXO
OXXXO
OXXXO
.OOO.
Output
.O.
OXO
.O.
OXXOOX
XOXOXO
XX..OO
OO..XX
OXOXOX
XOOXXO
.OXO.
OOXXO
XXOXX
OXXOO
.OXO.
----------------------------------------------------------------------------------------------------
D. Rating Compression
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
5
1 5 3 4 2
4
1 3 2 1
5
1 3 3 3 2
10
1 2 3 4 5 6 7 8 9 10
3
3 3 2
Output
10111
0001
00111
1111111111
000
----------------------------------------------------------------------------------------------------
E. Capitalism
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 6
1 2 0
3 2 0
2 5 0
6 5 1
6 3 0
2 4 1
Output
YES
3
3 2 1 3 1 0 
Input
4 4
1 2 1
2 3 0
3 4 1
4 1 1
Output
NO
Input
1 0
Output
YES
0
0 
----------------------------------------------------------------------------------------------------
F. The Struggling Contestant
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
7 1 2
comicom
Output
3 c m o
----------------------------------------------------------------------------------------------------
H1. Multithreading (Easy Version)
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 0
bwbb?www
Output
1
Input
10 0
???ww?wb??
Output
436731905
Input
4 0
bw?b
Output
0
----------------------------------------------------------------------------------------------------
H2. Multithreading (Hard Version)
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 0
bwbb?www
Output
1
Input
10 3
???ww?wb??
4 ?
5 ?
2 w
Output
436731905
218365953
374341633
530317313
Input
4 3
bw?b
1 w
2 b
1 w
Output
0
0
1
1
----------------------------------------------------------------------------------------------------
