Codeforces Round 480 (Div. 2)


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

Examples
Input
-o-o--
Output
YES
Input
-o---
Output
YES
Input
-o---o-
Output
NO
Input
ooo
Output
YES
----------------------------------------------------------------------------------------------------
B. Marlin
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7 2
Output
YES
.......
.#.....
.#.....
.......
Input
5 3
Output
YES
.....
.###.
.....
.....
----------------------------------------------------------------------------------------------------
C. Posterized
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3
2 14 3 4
Output
0 12 3 3
Input
5 2
0 2 1 255 254
Output
0 1 1 254 254
----------------------------------------------------------------------------------------------------
D. Perfect Groups
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
5 5
Output
3 0
Input
5
5 -4 2 1 8
Output
5 5 3 2 0
Input
1
0
Output
1
----------------------------------------------------------------------------------------------------
E. The Number Games
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 3
2 1
2 6
4 2
5 6
2 3
Output
1 3 4
Input
8 4
2 6
2 7
7 8
1 2
3 1
2 4
7 5
Output
1 3 4 5
----------------------------------------------------------------------------------------------------
F. Cactus to Tree
time limit per test: 4 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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