Intel Code Challenge Final Round (Div. 1 + Div. 2, Combined)


A. Checking the Calendar
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
monday
tuesday
Output
NO
Input
sunday
sunday
Output
YES
Input
saturday
tuesday
Output
YES
----------------------------------------------------------------------------------------------------
B. Batch Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 4
1 3 2 4
1 3 4 2
Output
YES
Input
4 4
1 2 3 4
2 3 4 1
3 4 1 2
4 1 2 3
Output
NO
Input
3 6
2 1 3 4 5 6
1 2 4 3 5 6
1 2 3 4 6 5
Output
YES
----------------------------------------------------------------------------------------------------
C. Ray Tracing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 4
1 1
1 2
2 1
2 2
Output
1
-1
-1
2
Input
3 4 6
1 1
2 1
1 2
2 2
1 3
2 3
Output
1
-1
-1
2
5
-1
Input
7 4 5
1 3
2 2
5 1
5 3
4 3
Output
13
2
9
5
-1
----------------------------------------------------------------------------------------------------
D. Dense Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
cbabc
Output
a
Input
2
abcab
Output
aab
Input
3
bcabcbaccba
Output
aaabb
----------------------------------------------------------------------------------------------------
E. Goods transportation
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 0
1 2 3
3 2 1
Output
4
Input
5 1
7 4 2 1 0
1 2 3 4 5
Output
12
Input
4 3
13 10 7 4
4 7 10 13
Output
34
----------------------------------------------------------------------------------------------------
F. Uniformly Branched Trees
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2 433416647
Output
1
Input
10 3 409693891
Output
2
Input
65 4 177545087
Output
910726
----------------------------------------------------------------------------------------------------
G. Xor-matic Number of the Graph
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 4
1 2 1
1 3 2
2 3 3
3 4 1
Output
12
Input
4 4
1 2 1
2 3 2
3 4 4
4 1 8
Output
90
Input
8 6
1 2 2
2 3 1
2 4 4
4 5 5
4 6 3
7 8 5
Output
62
----------------------------------------------------------------------------------------------------
