Codeforces Round 829 (Div. 2)


A. Technical Support
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
QQAA
4
QQAQ
3
QAA
1
Q
14
QAQQAQAAQQQAAA
Output
Yes
No
Yes
No
Yes
----------------------------------------------------------------------------------------------------
B. Kevin and Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
4
3
Output
2 4 1 3
1 2 3
----------------------------------------------------------------------------------------------------
C1. Make Nonzero Sum (easy version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
4
1 1 1 1
6
-1 1 1 1 1 1
3
1 -1 1
1
1
Output
1
1 4
2
1 3
4 6
-1
-1
----------------------------------------------------------------------------------------------------
C2. Make Nonzero Sum (hard version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
4
0 0 0 0
7
-1 1 0 1 0 1 0
5
0 -1 1 0 1
3
1 0 1
1
1
Output
4
1 1
2 2
3 3
4 4
4
1 1
2 2
3 5
6 7
-1
2
1 1
2 3
-1
----------------------------------------------------------------------------------------------------
D. Factorial Divisibility
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 4
3 2 2 2 3 3
Output
Yes
Input
8 3
3 2 2 2 2 2 1 1
Output
Yes
Input
7 8
7 7 7 7 7 7 7
Output
No
Input
10 5
4 3 2 1 4 3 2 4 3 4
Output
No
Input
2 500000
499999 499999
Output
No
----------------------------------------------------------------------------------------------------
E. Wish I Knew How to Sort
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3
0 1 0
5
0 0 1 1 1
6
1 1 1 0 0 1
Output
3
0
249561107
----------------------------------------------------------------------------------------------------
F. The Beach
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 5
5 2
.LR##
##LR.
Output
4
Input
2 3
4 5
LR.
#.#
Output
-1
Input
4 3
10 10
.LR
###
UU#
DD.
Output
-1
Input
3 6
10 7
.U##.#
#DLR##
.##LR.
Output
24
----------------------------------------------------------------------------------------------------
