Codeforces Beta Round 92 (Div. 1 Only)


A. Prime Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
abc
Output
YES
abc
Input
abcd
Output
NO
Input
xxxyxxx
Output
YES
xxxxxxy
----------------------------------------------------------------------------------------------------
B. Squares
time limit per test: 0.5 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2 2 1 0 0 1
Output
1
Input
2 2 10 11 0 1
Output
5
Input
2 4 3 -1 3 7
Output
2
----------------------------------------------------------------------------------------------------
C. Brackets
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1 2 1
1 2
Output
()
Input
2 3 1
1 2 3
4 5 6
Output
(()
())
Input
3 2 2
3 6
1 4
2 5
Output
()
)(
()
----------------------------------------------------------------------------------------------------
D. String
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
aaaa
Output
20
Input
abcdef
Output
21
Input
abacabadabacaba
Output
188
----------------------------------------------------------------------------------------------------
E. Maze
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
1 2
0 1
1 0
Output
1.00000000000000000000
Input
3
1 2
1 3
1 0
0 2
0 3
Output
2.00000000000000000000
Input
7
1 2
1 3
2 4
2 5
3 6
3 7
1 1
1 1
1 1
1 1
1 1
1 1
1 1
Output
4.04081632653
----------------------------------------------------------------------------------------------------
