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


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

Examples
Input
5
4 5 1 7 4
Output
1
8
01010
00011
01010
10010
00011
11000
00011
11000
Input
2
1 2
Output
0
2
11
11
Input
3
1 1 1
Output
1
0
----------------------------------------------------------------------------------------------------
B. Minimum and Maximum
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
2
 
>
 
3
 
=
 
=
 
Output
 
 
? 1 2
 
! 2 1
 
? 3 1
 
? 2 1
 
! 2 3
----------------------------------------------------------------------------------------------------
C. Bulmart
time limit per test: 1.5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
6 4
4 2
5 4
1 2
3 2
2
4 1 2
3 2 3
6
1 2 6
2 3 7
3 1 2
4 3 8
5 2 5
6 1 10
Output
2
-1
2
2
3
-1
----------------------------------------------------------------------------------------------------
D. Running Over The Bridges
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
1 3
7
10
Output
2
0 3
Input
3 3
3 3 3
3 3 2
Output
-1
Input
3 100000
5 5 5
5 7 8
Output
1
0 
Input
4 1000
1 2 3 4
10 9 10 9
Output
0
----------------------------------------------------------------------------------------------------
E. Award Ceremony
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
17 -14
52 -5
1 52
6 0
Output
4
Input
5
4 5
3 2
5 -3
6 -2
4 3
Output
14
----------------------------------------------------------------------------------------------------
F. Ber Patio
time limit per test: 3 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 21
12 75 52
Output
110
2 5 22 
Input
3 39
58 64 33
Output
107
28 4 16 
----------------------------------------------------------------------------------------------------
G. Car Repair Shop
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3
9 2
7 3
2 4
Output
9 10
1 3
4 7
Input
4
1000000000 1000000
1000000000 1000000
100000000 1000000
1000000000 1000000
Output
1000000000 1000999999
1 1000000
100000000 100999999
1000001 2000000
----------------------------------------------------------------------------------------------------
H. Delete Them
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 2
ab
ac
cd
1 2
Output
Yes
a?
Input
5 3
test
tezt
test.
.est
tes.
1 4 5
Output
Yes
?es?
Input
4 4
a
b
c
dd
1 2 3 4
Output
No
Input
6 3
.svn
.git
....
...
..
.
1 2 3
Output
Yes
.???
----------------------------------------------------------------------------------------------------
I. Olympiad in Programming and Sports
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5 2 2
1 3 4 5 2
5 3 2 1 4
Output
18
3 4 
1 5 
Input
4 2 2
10 8 8 3
10 7 9 4
Output
31
1 2 
3 4 
Input
5 3 1
5 2 5 1 7
6 3 1 6 3
Output
23
1 3 5 
4 
----------------------------------------------------------------------------------------------------
J. Bottles
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
3 3 4 3
4 7 6 5
Output
2 6
Input
2
1 1
100 100
Output
1 1
Input
5
10 30 5 6 24
10 41 7 8 24
Output
3 11
----------------------------------------------------------------------------------------------------
K. Roads Orientation Problem
time limit per test: 5 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
2
4 4 1 2
1 2
2 3
3 4
4 1
3 2 1 3
3 1
2 3
Output
Yes
1 2
3 2
4 3
1 4
No
----------------------------------------------------------------------------------------------------
L. Expression Queries
time limit per test: 4 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
((1+2)*3+101*2)
6
8 14
1 6
2 10
11 14
5 5
4 5
Output
205
-1
10
2
2
-1
Input
(01)
1
1 4
Output
1
----------------------------------------------------------------------------------------------------
