Codeforces Round 657 (Div. 2)


A. Acacius and String
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6
7
abacaba
7
???????
11
aba?abacaba
11
abacaba?aba
15
asdf???f???qwer
11
abacabacaba
Output
Yes
abacaba
Yes
abacaba
Yes
abadabacaba
Yes
abacabadaba
No
No
----------------------------------------------------------------------------------------------------
B. Dubious Cyrpto
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
4 6 13
2 3 1
Output
4 6 5
2 2 3
----------------------------------------------------------------------------------------------------
C. Choosing flowers
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
4 3
5 0
1 4
2 2
5 3
5 2
4 2
3 1
Output
14
16
----------------------------------------------------------------------------------------------------
D. New Passenger Trams
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2 24 60 15
16 0
17 15
Output
0 0
Input
2 24 60 16
16 0
17 15
Output
1 0
2 
----------------------------------------------------------------------------------------------------
E. Inverse Genealogy
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 0
Output
YES
0 1 1
Input
5 1
Output
YES
0 1 1 3 3
Input
3 2
Output
NO
----------------------------------------------------------------------------------------------------
F1. Chess Strikes Back (easy version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 3 3
1 1
1 5
2 4
Output
YES
YES
NO
Input
3 2 7
4 2
6 4
1 3
2 2
2 4
4 4
3 1
Output
YES
YES
NO
NO
NO
NO
NO
----------------------------------------------------------------------------------------------------
F2. Chess Strikes Back (hard version)
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 3 3
1 1
1 5
2 4
Output
YES
YES
NO
Input
3 2 10
4 2
6 4
1 3
4 2
6 4
2 2
2 4
1 3
4 4
3 1
Output
YES
YES
NO
NO
YES
YES
NO
YES
YES
NO
----------------------------------------------------------------------------------------------------
