Kotlin Heroes: Practice 8


A. A+B (Trial Problem)
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
4
1 5
314 15
-99 99
123 987
Output
6
329
0
1110
----------------------------------------------------------------------------------------------------
B. Yellow Cards
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
2
3
5
1
8
Output
0 4
Input
3
1
6
7
25
Output
4 4
Input
6
4
9
10
89
Output
5 9
----------------------------------------------------------------------------------------------------
C. Shooting
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
3
20 10 20
Output
43
1 3 2 
Input
4
10 10 10 10
Output
64
2 1 4 3 
Input
6
5 4 5 4 4 5
Output
69
6 1 3 5 2 4 
Input
2
1 4
Output
3
2 1 
----------------------------------------------------------------------------------------------------
D. Reachable Numbers
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
1098
Output
20
Input
10
Output
19
----------------------------------------------------------------------------------------------------
E. Erasing Zeroes
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
3
010011
0
1111000
Output
2
0
0
----------------------------------------------------------------------------------------------------
F. Square Filling
time limit per test: 2.0 s
memory limit per test: 512 MB
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
----------------------------------------------------------------------------------------------------
G. XOR Guessing
time limit per test: 2.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
0
32
Output
? 3 5 6
? 32 24 37
! 5
----------------------------------------------------------------------------------------------------
H. Chainword
time limit per test: 6.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
3 5
ababa
ab
a
Output
11
Input
2 4
ab
cd
Output
4
Input
5 100
a
aa
aaa
aaaa
aaaaa
Output
142528942
----------------------------------------------------------------------------------------------------
I. Minimum Difference
time limit per test: 10.0 s
memory limit per test: 512 MB
input: standard input
output: standard output

Examples
Input
12 11
2 1 1 2 1 1 3 2 1 1 3 3
1 2 10 3
1 2 11 3
2 7 2
1 3 9 2
1 1 12 1
1 1 12 4
2 12 4
1 1 12 4
2 1 5
1 3 12 2
1 1 4 3
Output
5
4
1
0
-1
5
0
1
----------------------------------------------------------------------------------------------------
