Educational Codeforces Round 64 (Rated for Div. 2)


A. Inscribed Figures
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
2 1 3
Output
Finite
7
Input
3
1 2 3
Output
Infinite
----------------------------------------------------------------------------------------------------
B. Ugly Pairs
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
abcd
gg
codeforces
abaca
Output
cadb
gg
codfoerces
No answer
----------------------------------------------------------------------------------------------------
C. Match Points
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 2
1 3 3 7
Output
2
Input
5 5
10 9 5 8 7
Output
1
----------------------------------------------------------------------------------------------------
D. 0-1-Tree
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2 1 1
3 2 0
4 2 1
5 2 0
6 7 1
7 2 1
Output
34
----------------------------------------------------------------------------------------------------
E. Special Segments of Permutation
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
3 4 1 5 2
Output
2
Input
3
1 3 2
Output
1
----------------------------------------------------------------------------------------------------
F. Card Bag
time limit per test: 2 seconds
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
5
1 1 4 2 3
Output
299473306
Input
2
2 2
Output
1
Input
5
4 5 1 3 2
Output
0
Input
4
1 3 4 3
Output
748683265
----------------------------------------------------------------------------------------------------
G. Optimizer
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
c=aa#bb
d12=c
res=c^d12
tmp=aa$c
Output
2
aaaa=aa#bb
res=aaaa^aaaa
Input
2
max=aaaa$bbbb
min=bbbb^aaaa
Output
0
----------------------------------------------------------------------------------------------------
