AIM Tech Poorly Prepared Contest (unrated, funny, Div. 1 preferred)


A. Nash equilibrium
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
5 4
1 2
2 3
3 4
4 5
Output
55
Input
12 6
1 2
3 4
5 6
8 7
10 9
12 11
Output
30
Input
7 6
1 2
1 3
2 4
2 5
3 6
3 7
Output
45
----------------------------------------------------------------------------------------------------
C. Segment tree or Fenwick?
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 3
1 2 5
2 3 1
1 3 7
Output
6
----------------------------------------------------------------------------------------------------
E. Amazing bitset
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 1 2
Output
848765426
Input
1 228 239
Output
0
----------------------------------------------------------------------------------------------------
F. Keep talking and nobody explodes – easy
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
00000
Output
61376
Input
12345
Output
07769
----------------------------------------------------------------------------------------------------
G. Keep talking and nobody explodes – medium
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
00000
Output
43266
Input
12345
Output
87229
----------------------------------------------------------------------------------------------------
H. Who needs suffix structures?
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
1 2 3 1 2
2 1 4
3 1 3
Output
Yes
No
Input
9 3
0 0 0 0 0 0 0 0 0
9 1 1
8 1 2
1 1 9
Output
Yes
Yes
Yes
----------------------------------------------------------------------------------------------------
I. Deja vu
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 2
01101
Output
3
Input
10 3
1110001011
Output
8
----------------------------------------------------------------------------------------------------
J. Keep talking and nobody explodes – hard
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Output
9700010006000300020000111706617034943099970012861000908700093104145749080706326060507070104603727696
Input
1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890
Output
0434577839123736809081959678791214963899953499955062244348594338577599113453106002302374004287484136
----------------------------------------------------------------------------------------------------
