Codeforces Round 501 (Div. 3)


A. Points in Segments
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5
2 2
1 2
5 5
Output
2
3 4 
Input
1 7
1 7
Output
0
----------------------------------------------------------------------------------------------------
B. Obtaining the String
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6
abcdef
abdfec
Output
4
3 5 4 5 
Input
4
abcd
accd
Output
-1
----------------------------------------------------------------------------------------------------
C. Songs Compression
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 21
10 8
7 4
3 1
5 4
Output
2
Input
4 16
10 8
7 4
3 1
5 4
Output
-1
----------------------------------------------------------------------------------------------------
D. Walking Between Houses
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
10 2 15
Output
YES
10 4 
Input
10 9 45
Output
YES
10 1 10 1 2 1 2 1 6 
Input
10 9 81
Output
YES
10 1 10 1 10 1 10 1 10 
Input
10 9 82
Output
NO
----------------------------------------------------------------------------------------------------
E1. Stars Drawing (Easy Edition)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
----------------------------------------------------------------------------------------------------
E2. Stars Drawing (Hard Edition)
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 8
....*...
...**...
..*****.
...**...
....*...
........
Output
3
3 4 1
3 5 2
3 5 1
Input
5 5
.*...
****.
.****
..**.
.....
Output
3
2 2 1
3 3 1
3 4 1
Input
5 5
.*...
***..
.*...
.*...
.....
Output
-1
Input
3 3
*.*
.*.
*.*
Output
-1
----------------------------------------------------------------------------------------------------
F. Bracket Substring
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
()))()
Output
5
Input
3
(()
Output
4
Input
2
(((
Output
0
----------------------------------------------------------------------------------------------------
