CROC-MBTU 2012, Final Round (Online version, Div. 2)


A. Paper Work
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
11
1 2 3 -4 -5 -6 5 -5 -6 -7 6
Output
3
5 3 3 
Input
5
0 -1 100 -1 0
Output
1
5 
----------------------------------------------------------------------------------------------------
B. Restoring IPv6
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
a56f:d3:0:0124:01:f19a:1000:00
a56f:00d3:0000:0124:0001::
a56f::0124:0001:0000:1234:0ff0
a56f:0000::0000:0001:0000:1234:0ff0
::
0ea::4d:f4:6:0
Output
a56f:00d3:0000:0124:0001:f19a:1000:0000
a56f:00d3:0000:0124:0001:0000:0000:0000
a56f:0000:0000:0124:0001:0000:1234:0ff0
a56f:0000:0000:0000:0001:0000:1234:0ff0
0000:0000:0000:0000:0000:0000:0000:0000
00ea:0000:0000:0000:004d:00f4:0006:0000
----------------------------------------------------------------------------------------------------
C. Movie Critics
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 3
1 1 2 3 2 3 3 1 1 3
Output
3
Input
7 3
3 1 3 2 3 1 2
Output
1
----------------------------------------------------------------------------------------------------
D. Building Bridge
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 3 5
-2 -1 4
-1 2
7 3
Output
2 2
----------------------------------------------------------------------------------------------------
E. Mad Joe
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
..+.#
#+..+
+.#+.
Output
14
Input
4 10
...+.##+.+
+#++..+++#
++.#++++..
.+##.++#.+
Output
42
Input
2 2
..
++
Output
Never
----------------------------------------------------------------------------------------------------
