Codeforces Round 856 (Div. 2)


A. Prefix and Suffix Array
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
bcd cd a d abc ab
3
i io i oi
2
g g
3
t al lt a
4
bba a ab a abb ba
Output
NO
YES
YES
NO
YES
----------------------------------------------------------------------------------------------------
B. Not Dividing
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
4
2 4 3 6
3
1 2 3
2
4 2
Output
4 5 6 7
3 2 3
4 2
----------------------------------------------------------------------------------------------------
C. Scoring Subsequences
time limit per test: 2.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
1 2 3
2
1 1
5
5 5 5 5 5
Output
1 1 2 
1 1 
1 2 3 4 5 
----------------------------------------------------------------------------------------------------
D. Counting Factorizations
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 3 2 3
Output
2
Input
2
2 2 3 5
Output
5
Input
1
1 4
Output
0
----------------------------------------------------------------------------------------------------
E. Labeling the Tree with Distances
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
2 1 0 1 2
1 2
2 3
2 4
4 5
4 6
Output
2
2 4 
Input
5
1 2 1 2
1 2
3 2
3 4
5 4
Output
1
3 
Input
3
2 2
1 2
2 3
Output
0
----------------------------------------------------------------------------------------------------
