Educational Codeforces Round 71 (Rated for Div. 2)


A. There Are Two Types Of Burgers
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
15 2 3
5 10
7 5 2
10 12
1 100 100
100 100
Output
40
34
0
----------------------------------------------------------------------------------------------------
B. Square Filling
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3
1 1 1
1 1 1
0 1 1
Output
3
1 1
1 2
2 2
Input
3 3
1 0 1
1 0 1
0 0 0
Output
-1
Input
3 2
0 0
0 0
0 0
Output
0
----------------------------------------------------------------------------------------------------
C. Gas Pipeline
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
8 2 5
00110010
8 1 1
00110010
9 100000000 100000000
010101010
2 5 1
00
Output
94
25
2900000000
13
----------------------------------------------------------------------------------------------------
D. Number Of Permutations
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 1
2 2
3 1
Output
3
Input
4
2 3
2 2
2 1
2 4
Output
0
Input
3
1 1
1 1
2 3
Output
4
----------------------------------------------------------------------------------------------------
E. XOR Guessing
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0
32
Output
? 3 5 6
? 32 24 37
! 5
----------------------------------------------------------------------------------------------------
F. Remainder Problem
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 3 4
2 3 0
2 4 3
1 4 -4
2 1 0
Output
4
4
0
----------------------------------------------------------------------------------------------------
G. Indie Album
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
20
1 d
2 1 a
2 2 d
2 3 a
2 4 d
2 5 a
2 6 d
2 7 a
1 d
2 9 o
2 10 k
2 11 i
2 12 d
2 13 o
2 14 k
2 15 i
2 1 o
2 17 k
2 18 i
2 15 i
12
8 da
8 dada
8 ada
6 dada
3 dada
19 doki
19 ok
16 doki
15 doki
9 d
1 a
20 doki
Output
4
3
3
2
0
1
1
2
1
1
0
2
----------------------------------------------------------------------------------------------------
