Intel Code Challenge Elimination Round (Div. 1 + Div. 2, combined)


A. Broken Clock
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
24
17:30
Output
17:30
Input
12
17:30
Output
07:30
Input
24
99:99
Output
09:09
----------------------------------------------------------------------------------------------------
B. Verse Pattern
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 2 3
intel
code
ch allenge
Output
YES
Input
4
1 2 3 1
a
bcdefghi
jklmnopqrstu
vwxyz
Output
NO
Input
4
13 11 15 15
to be or not to be that is the question
whether tis nobler in the mind to suffer
the slings and arrows of outrageous fortune
or to take arms against a sea of troubles
Output
YES
----------------------------------------------------------------------------------------------------
C. Destroying Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1 3 2 5
3 4 1 2
Output
5
4
3
0
Input
5
1 2 3 4 5
4 2 3 5 1
Output
6
5
5
1
0
Input
8
5 5 4 4 6 6 5 5
5 2 8 7 1 3 4 6
Output
18
16
11
8
8
6
6
0
----------------------------------------------------------------------------------------------------
D. Generating Sets
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 2 3 4 5
Output
4 5 2 3 1 
Input
6
15 14 3 13 1 12
Output
12 13 14 7 3 1 
Input
6
9 7 13 17 5 11
Output
4 5 2 6 3 1 
----------------------------------------------------------------------------------------------------
E. Research Rover
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 2 11
2 1
2 3
Output
333333342
Input
4 5 3 17
1 2
3 3
4 1
Output
514285727
Input
1 6 2 15
1 1
1 5
Output
4
----------------------------------------------------------------------------------------------------
F. Cyclic Cipher
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 4
3 3 4 1
4 1 3 4 2
3 3 1 4
Output
2
1
3
2
Input
5 5
2 3 1
4 5 1 3 2
4 2 1 3 5
1 3
2 5 3
Output
3
1
4
0
1
Input
4 6
3 4 5 3
2 6 3
2 3 6
3 3 6 5
Output
0
0
2
1
1
2
----------------------------------------------------------------------------------------------------
