Forethought Future Cup - Final Round (Onsite Finalists Only)


A. Hide and Seek
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5 3
5 1 4
Output
9
Input
4 8
1 2 3 4 4 3 2 1
Output
0
Input
100000 1
42
Output
299997
----------------------------------------------------------------------------------------------------
B. Chladni Figure
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
12 6
1 3
3 7
5 7
7 11
9 11
11 3
Output
Yes
Input
9 6
4 5
5 6
7 8
8 9
1 2
2 3
Output
Yes
Input
10 3
1 2
3 2
7 2
Output
No
Input
10 2
1 6
2 7
Output
Yes
----------------------------------------------------------------------------------------------------
C. Thanos Nim
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
8 8
Output
Bob
Input
4
3 1 4 1
Output
Alice
----------------------------------------------------------------------------------------------------
D. Palindrome XOR
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10110
Output
3
Input
1?0???10
Output
44
Input
1?????????????????????????????????????
Output
519569202
Input
1
Output
0
----------------------------------------------------------------------------------------------------
E. Rainbow Coins
time limit per test: 6 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1
1
1
3
1
0
0
6
000
010
100
001
000
Output
Q 1 1 2
Q 1 2 3
Q 1 1 3
A 3 0 0
1 2 3
Q 1 1 3
Q 1 2 3
Q 1 1 2
A 2 0 1
1 3
2
Q 3 1 2 3 4 5 6
Q 3 1 3 2 5 4 6
Q 3 1 4 2 6 3 5
Q 3 1 5 2 4 3 6
Q 3 1 6 2 3 4 5
A 2 2 2
1 4
2 5
3 6
----------------------------------------------------------------------------------------------------
F. Zigzag Game
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
3 1 9
2 5 7
6 4 8
6
-1
1
1
I 1
-1
Output
A
D 3
2
B
2
----------------------------------------------------------------------------------------------------
