Technocup 2020 - Elimination Round 4


A. Happy Birthday, Polycarp!
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
18
1
9
100500
33
1000000000
Output
10
1
9
45
12
81
----------------------------------------------------------------------------------------------------
B. Make Them Odd
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
6
40 6 40 3 20 1
1
1024
4
2 4 8 16
3
3 1 7
Output
4
10
4
0
----------------------------------------------------------------------------------------------------
C. As Simple as One and Two
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
onetwone
testme
oneoneone
twotwo
Output
2
6 3
0
3
4 1 7 
2
1 4
Input
10
onetwonetwooneooonetwooo
two
one
twooooo
ttttwo
ttwwoo
ooone
onnne
oneeeee
oneeeeeeetwooooo
Output
6
18 11 12 1 6 21 
1
1 
1
3 
1
2 
1
6 
0
1
4 
0
1
1 
2
1 11 
----------------------------------------------------------------------------------------------------
D. Let's Play the Words?
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
0001
1000
0011
0111
3
010
101
0
2
00000
00001
4
01
001
0001
00001
Output
1
3 
-1
0
2
1 2 
----------------------------------------------------------------------------------------------------
E. Two Fairs
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
7 7 3 5
1 2
2 3
3 4
4 5
5 6
6 7
7 5
4 5 2 3
1 2
2 3
3 4
4 1
4 2
4 3 2 1
1 2
2 3
4 1
Output
4
0
1
----------------------------------------------------------------------------------------------------
F. Beautiful Rectangle
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12
3 1 4 1 5 9 2 6 5 3 5 8
Output
12
3 4
1 2 3 5
3 1 5 4
5 6 8 9
Input
5
1 1 1 1 1
Output
1
1 1
1
----------------------------------------------------------------------------------------------------
G. Tree Elimination
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2
1 3
1 4
1 5
Output
5
Input
7
7 2
7 6
1 2
7 5
4 7
3 5
Output
10
----------------------------------------------------------------------------------------------------
