Codeforces Round 872 (Div. 2)


A. LuoTianyi and the Palindrome String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abacaba
aaa
codeforcesecrofedoc
lol
Output
6
-1
18
2
----------------------------------------------------------------------------------------------------
B. LuoTianyi and the Table
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
2 2
1 3 1 4
2 2
-1 -1 -1 -1
2 3
7 8 9 -3 10 8
3 2
4 8 -3 0 -7 1
4 3
-32030 59554 16854 -85927 68060 -64460 -79547 90932 85063 82703 -12001 38762
Output
9
0
64
71
1933711
----------------------------------------------------------------------------------------------------
C. LuoTianyi and the Show
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10
3 10
5 5 5
4 6
1 -2 -2 1
5 7
-1 -1 4 -2 -2
6 7
5 -2 -2 -2 -2 -2
6 6
-1 1 4 5 -1 4
6 8
-1 -1 -1 3 -1 -2
6 7
5 -1 -2 -2 -2 -2
3 1
-2 -2 1
2 5
5 -2
1 2
-1
Output
1
3
5
6
5
5
5
1
2
1
----------------------------------------------------------------------------------------------------
D1. LuoTianyi and the Floating Islands (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 2
2 3
3 4
Output
666666674
Input
5 1
1 2
2 3
3 4
3 5
Output
1
----------------------------------------------------------------------------------------------------
D2. LuoTianyi and the Floating Islands (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 2
2 3
3 4
Output
666666674
Input
5 5
1 2
2 3
3 4
3 5
Output
1
----------------------------------------------------------------------------------------------------
E. LuoTianyi and XOR-Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
3 5 7 5 8 4
1 2
1 3
1 4
3 5
4 6
Output
3
Input
8
7 10 7 16 19 9 16 11
1 5
4 2
6 5
5 2
7 2
2 3
3 8
Output
3
Input
4
1 2 1 2
1 2
2 3
4 3
Output
0
Input
9
4 3 6 1 5 5 5 2 7
1 2
2 3
4 1
4 5
4 6
4 7
8 1
8 9
Output
2
----------------------------------------------------------------------------------------------------
