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


A. Automatic Door
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 1 3 4
7
Output
1
Input
4 3 4 2
7 9 11
Output
4
----------------------------------------------------------------------------------------------------
B. Berland Army
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3 3
0 3 0 0 2
2 4
3 4
3 5
Output
1 3 3 2 2 
Input
7 6 5
0 4 5 4 1 0 0
6 1
3 6
3 1
7 5
7 1
7 4
Output
2 4 5 4 1 3 5 
Input
2 2 2
2 1
1 2
2 1
Output
-1
----------------------------------------------------------------------------------------------------
C. Downloading B++
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
120 964 20
26 8 8
13 10 4
Output
40
Input
10 200 20
1 1 1
2 2 3
Output
0
Input
8 81 11
4 10 16
3 10 12
Output
28
Input
8 79 11
4 10 16
3 10 12
Output
-1
----------------------------------------------------------------------------------------------------
D. Packmen Strike Back
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
*.P*P*
Output
3 4
Input
8
*...P..*
Output
1 3
----------------------------------------------------------------------------------------------------
E. Field of Wonders
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
a**d
2
abcd
acbd
Output
2
Input
5
lo*er
2
lover
loser
Output
0
Input
3
a*a
2
aaa
aba
Output
1
----------------------------------------------------------------------------------------------------
F. Lost in Transliteration
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
mihail
oolyana
kooooper
hoon
ulyana
koouper
mikhail
khun
kuooper
kkkhoon
Output
4
Input
9
hariton
hkariton
buoi
kkkhariton
boooi
bui
khariton
boui
boi
Output
5
Input
2
alex
alex
Output
1
----------------------------------------------------------------------------------------------------
G. Orientation of Edges
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1
1 1 2
2 2 1
Output
2
-
2
+
Input
6 6 3
2 2 6
1 4 5
2 3 4
1 4 1
1 3 1
2 2 3
Output
6
++-
2
+-+
----------------------------------------------------------------------------------------------------
H. Palindromic Cut
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
aabaac
Output
2
aba aca 
Input
8
0rTrT022
Output
1
02TrrT20 
Input
2
aA
Output
2
a A 
----------------------------------------------------------------------------------------------------
I. Photo Processing
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
50 110 130 40 120
Output
20
Input
4 1
2 3 4 1
Output
0
----------------------------------------------------------------------------------------------------
J. Renovation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 3
2 4
6 2 3
1 3 2
Output
2
Input
3 5
5 3 1
5 2 9 1 10
4 2 1 3 10
Output
3
Input
5 6
6 3 2 4 3
3 6 4 5 4 2
1 4 3 2 5 3
Output
6
----------------------------------------------------------------------------------------------------
K. Road Widening
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4 5
4 5
4 10
Output
16
9 9 10 
Input
4
1 100
100 1
1 100
100 1
Output
202
101 101 101 101 
Input
3
1 1
100 100
1 1
Output
-1
----------------------------------------------------------------------------------------------------
L. Berland.Taxi
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 1 2
3
5 2 8
9 10 3
Output
1 1
1 5
Input
5 2 1
1 5
10 3 5
Output
1 2
Input
5 2 2
1 5
10 3 5
20 4 1
Output
1 2
2 1
----------------------------------------------------------------------------------------------------
M. Quadcopter Competition
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 5
5 2
Output
18
Input
0 1
0 0
Output
8
----------------------------------------------------------------------------------------------------
