Technocup 2020 - Elimination Round 2


A. Forgetting Things
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 2
Output
199 200
Input
4 4
Output
412 413
Input
5 7
Output
-1
Input
6 2
Output
-1
----------------------------------------------------------------------------------------------------
B1. TV Subscriptions (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2 2
1 2 1 2 1
9 3 3
3 3 3 2 2 2 1 1 1
4 10 4
10 8 6 4
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
Output
2
1
4
5
----------------------------------------------------------------------------------------------------
B2. TV Subscriptions (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2 2
1 2 1 2 1
9 3 3
3 3 3 2 2 2 1 1 1
4 10 4
10 8 6 4
16 9 8
3 1 4 1 5 9 2 6 5 3 5 8 9 7 9 3
Output
2
1
4
5
----------------------------------------------------------------------------------------------------
C. p-binary
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
24 0
Output
2
Input
24 1
Output
3
Input
24 -1
Output
4
Input
4 -7
Output
2
Input
1 1
Output
-1
----------------------------------------------------------------------------------------------------
D. Power Products
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 3
1 3 9 8 24 1
Output
5
----------------------------------------------------------------------------------------------------
E. Rock Is Push
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 1
.
Output
1
Input
2 3
...
..R
Output
0
Input
4 4
...R
.RR.
.RR.
R...
Output
4
----------------------------------------------------------------------------------------------------
F. Tree Factory
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

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

Examples
Input
2 2
1 1
Output
YES
1 1
Input
4 3
7 8 13 23
Output
YES
23 13
8 7
5 4
Input
3 4
1 2 3
Output
NO
----------------------------------------------------------------------------------------------------
