Technocup 2021 - Elimination Round 3


A. In-game Chat
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2
))
12
gl))hf))))))
9
gege)))))
14
)aa))b))))))))
1
)
Output
Yes
No
Yes
Yes
Yes
----------------------------------------------------------------------------------------------------
B. Fair Numbers
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
282
1234567890
1000000000000000000
Output
1
288
1234568040
1000000000000000000
----------------------------------------------------------------------------------------------------
C. Peaceful Rooks
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 1
2 3
3 2
2 1
1 2
5 3
2 3
3 1
1 2
5 4
4 5
5 1
2 2
3 3
Output
1
3
4
2
----------------------------------------------------------------------------------------------------
D. Grime Zoo
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0?1
2 3
Output
4
Input
?????
13 37
Output
0
Input
?10?
239 7
Output
28
Input
01101001
5 7
Output
96
----------------------------------------------------------------------------------------------------
E. Poman Numbers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 -1
ba
Output
Yes
Input
3 -7
abc
Output
No
Input
7 -475391
qohshra
Output
Yes
----------------------------------------------------------------------------------------------------
F. The Thorny Path
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
2 3 1
3
2 1 3
3
1 2 3
Output
3 0
3 1
3 2
Input
5
4
2 3 4 1
4
2 3 1 4
4
2 1 4 3
4
2 1 3 4
4
1 2 3 4
Output
4 0
4 1
4 0
4 1
4 2
----------------------------------------------------------------------------------------------------
G. No Game No Life
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 0
Output
0
Input
2 1
1 2
Output
332748118
Input
5 5
1 4
5 2
4 3
1 5
5 4
Output
931694730
----------------------------------------------------------------------------------------------------
