2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)


A. Find a Number
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
13 50
Output
699998
Input
61 2
Output
1000000000000000000000000000001
Input
15 50
Output
-1
----------------------------------------------------------------------------------------------------
B. Berkomnadzor
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
-149.154.167.99
Output
1
0.0.0.0/0
Input
4
-149.154.167.99
+149.154.167.100/30
+149.154.167.128/25
-149.154.167.120/29
Output
2
149.154.167.99
149.154.167.120/29
Input
5
-127.0.0.4/31
+127.0.0.8
+127.0.0.0/30
-195.82.146.208/29
-127.0.0.6/31
Output
2
195.0.0.0/8
127.0.0.4/30
Input
2
+127.0.0.1/32
-127.0.0.1
Output
-1
----------------------------------------------------------------------------------------------------
C. Cloud Computing
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 7 3
1 4 5 3
1 3 5 2
2 5 10 1
Output
44
Input
7 13 5
2 3 10 7
3 5 10 10
1 2 10 6
4 5 10 9
3 4 10 8
Output
462
Input
4 100 3
3 3 2 5
1 1 3 2
2 4 4 4
Output
64
----------------------------------------------------------------------------------------------------
D. Garbage Disposal
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
3 2 1
Output
3
Input
5 1
1000000000 1000000000 1000000000 1000000000 1000000000
Output
5000000000
Input
3 2
1 0 1
Output
2
Input
4 4
2 8 4 1
Output
4
----------------------------------------------------------------------------------------------------
E. Getting Deals Done
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
5 2 16
5 6 1 4 7
5 3 30
5 6 1 4 7
6 4 15
12 5 15 7 20 17
1 1 50
100
Output
3 5
4 7
2 10
0 25
Input
3
11 1 29
6 4 3 7 5 3 4 7 3 5 3
7 1 5
1 1 1 1 1 1 1
5 2 18
2 3 3 7 5
Output
4 3
3 1
4 5
----------------------------------------------------------------------------------------------------
F. Debate
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
11 6
10 4
01 3
00 3
00 7
00 9
Output
22
Input
5
11 1
01 1
00 100
10 1
01 1
Output
103
Input
6
11 19
10 22
00 18
00 29
11 29
10 28
Output
105
Input
3
00 5000
00 5000
00 5000
Output
0
----------------------------------------------------------------------------------------------------
G. Monsters and Potions
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8 3
8 2
1 3
4 9
0 3 -5 0 -5 -4 -1 0
Output
6
3 1 2 
Input
1 1
1 1
0
Output
1
1 
Input
3 2
1 1
3 1
0 -5000 0
Output
-1
Input
8 3
1 15
5 10
8 1
0 -5 -5 -5 0 -5 -5 0
Output
7
2 1 3 
----------------------------------------------------------------------------------------------------
H. BerOS File Suggestion
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
test
contests
test.
.test
6
ts
.
st.
.test
contes.
st
Output
1 contests
2 .test
1 test.
1 .test
0 -
4 test.
----------------------------------------------------------------------------------------------------
I. Privatization of Roads in Berland
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 3 2
1 2
2 3
3 1
4 5 2
1 2
1 3
1 4
2 3
2 4
4 6 2
1 2
1 3
1 4
2 3
2 4
3 4
Output
1 2 3 
2 1 1 2 3 
0 0 0 0 0 0 
----------------------------------------------------------------------------------------------------
J. Streets and Avenues in Berhattan
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3 9
EEZZEEZZZ
2 7 9
EEZZEEZZZ
Output
0
4
Input
2
4 4 8
CZBBCZBC
1 1 4
TTCT
Output
1
0
----------------------------------------------------------------------------------------------------
K. Video Posts
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
3 3 1 4 1 6
Output
Yes
2 3 1 
Input
3 3
1 1 1
Output
Yes
1 1 1 
Input
3 3
1 1 2
Output
No
Input
3 1
1 10 100
Output
Yes
3 
----------------------------------------------------------------------------------------------------
L. Odd Federalization
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
 
5 3
1 2
2 5
1 5
 
6 5
1 2
2 3
3 4
4 2
4 1
Output
1
1 1 1 1 1 
2
2 1 1 1 1 1
----------------------------------------------------------------------------------------------------
M. Algoland and Berland
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2 3
1 1 2
0 0
1 1
1 2
3 2
4 0
1 1
1
0 0
0 1
Output
YES
2 2
1 2
3 2
3 1
YES
1 1
----------------------------------------------------------------------------------------------------
