Codeforces Round 913 (Div. 3)


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

Examples
Input
1
d5
Output
d1
d2
b5
g5
h5
d3
e5
f5
d8
a5
d6
d7
c5
d4
----------------------------------------------------------------------------------------------------
B. YetnotherrokenKeoard
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12
ARaBbbitBaby
YetAnotherBrokenKeyboard
Bubble
Improbable
abbreviable
BbBB
BusyasaBeeinaBedofBloomingBlossoms
CoDEBARbIES
codeforces
bobebobbes
b
TheBBlackbboard
Output
ity
YetnotherrokenKeoard
le
Imprle
revile
usyasaeeinaedofloominglossoms
CDARIES
codeforces
es
helaoard
----------------------------------------------------------------------------------------------------
C. Removal of Unattractive Pairs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
4
aabc
5
abaca
10
avbvvcvvvd
7
abcdefg
5
dabbb
8
aacebeaa
7
bbbbacc
6
dacfcc
6
fdfcdc
9
dbdcfbbdc
Output
0
1
2
1
1
0
1
0
0
1
----------------------------------------------------------------------------------------------------
D. Jumping Through Segments
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5
1 5
3 4
5 6
8 10
0 1
3
0 2
0 1
0 3
3
3 8
10 18
6 11
4
10 20
0 5
15 17
2 2
Output
7
0
5
13
----------------------------------------------------------------------------------------------------
E. Good Triples
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12
11
0
1
2
3
4
5
3141
999
2718
9999999
10000000
Output
9
1
3
6
10
15
21
1350
166375
29160
1522435234375
3
----------------------------------------------------------------------------------------------------
F. Shift and Reverse
time limit per test: 2.0 s
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
5
3 2 1 5 4
5
1 1 2 1 1
4
3 7 10 5
5
1 2 3 4 5
2
5 1
3
3 4 1
5
4 1 3 4 4
3
5 1 1
4
2 5 5 4
5
2 2 1 1 2
2
5 5
Output
3
2
-1
0
1
1
3
1
2
2
0
----------------------------------------------------------------------------------------------------
G. Lights
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
5
11101
4 3 4 2 2
2
10
2 1
10
0000000011
9 10 10 7 10 9 9 9 10 2
10
1000111101
9 3 8 9 2 1 3 7 2 7
10
0001101010
5 7 6 10 8 3 6 6 2 2
10
0101100010
8 7 7 9 9 4 1 4 2 7
10
1010111010
7 9 10 7 7 2 8 6 10 4
10
1110000001
3 10 10 1 10 8 6 3 2 1
Output
3
1 5 3 
-1
1
9 
5
5 6 10 2 3 
6
4 9 5 10 8 7 
3
5 4 9 
6
1 3 5 9 7 8 
2
2 1 
----------------------------------------------------------------------------------------------------
