Codeforces Round 396 (Div. 2)


A. Mahmoud and Longest Uncommon Subsequence
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abcd
defgh
Output
5
Input
a
a
Output
-1
----------------------------------------------------------------------------------------------------
B. Mahmoud and a Triangle
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 5 3 2 4
Output
YES
Input
3
4 1 2
Output
NO
----------------------------------------------------------------------------------------------------
C. Mahmoud and a Message
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
aab
2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Output
3
2
2
Input
10
abcdeabcde
5 5 5 5 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Output
401
4
3
----------------------------------------------------------------------------------------------------
D. Mahmoud and a Dictionary
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 3 4
hate love like
1 love like
2 love hate
1 hate like
love like
love hate
like hate
hate like
Output
YES
YES
NO
1
2
2
2
Input
8 6 5
hi welcome hello ihateyou goaway dog cat rat
1 hi welcome
1 ihateyou goaway
2 hello ihateyou
2 hi goaway
2 hi hello
1 hi hello
dog cat
dog hi
hi hello
ihateyou goaway
welcome ihateyou
Output
YES
YES
YES
YES
NO
YES
3
3
1
1
2
----------------------------------------------------------------------------------------------------
E. Mahmoud and a xor trip
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
1 2
2 3
Output
10
Input
5
1 2 3 4 5
1 2
2 3
3 4
3 5
Output
52
Input
5
10 9 8 7 6
1 2
2 3
3 4
3 5
Output
131
----------------------------------------------------------------------------------------------------
