Codeforces Round 745 (Div. 2)


A. CQXYM Count Permutations
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
2
9
91234
Output
1
12
830455698
890287984
----------------------------------------------------------------------------------------------------
B. Diameter of Graph
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
5
1 0 3
4 5 3
4 6 3
5 4 1
2 1 1
Output
YES
NO
YES
NO
NO
----------------------------------------------------------------------------------------------------
C. Portal
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
1
5 4
1000
0000
0110
0000
0001
Output
12
Input
1
9 9
001010001
101110100
000010011
100000001
101010101
110001111
000001111
111100000
000110000
Output
5
----------------------------------------------------------------------------------------------------
D. Mathematics Curriculum
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4 3 2 10007
Output
4
Input
6 4 1 769626776
Output
472
Input
66 11 9 786747482
Output
206331312
Input
99 30 18 650457567
Output
77365367
----------------------------------------------------------------------------------------------------
E. Train Maintenance
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
3 4
10 15
12 10
1 1
1 3
1 1
2 1
2 3
Output
0
1
0
0
Input
5 4
1 1
10000000 100000000
998244353 1
2 1
1 2
1 5
2 5
1 5
1 1
Output
0
0
0
1
----------------------------------------------------------------------------------------------------
F. Subsequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
6 4
15 2 18 12 13 4
Output
100
Input
11 5
9 3 7 1 8 12 10 20 15 18 5
Output
176
Input
1 1
114514
Output
0
Input
2 1
666 888
Output
0
----------------------------------------------------------------------------------------------------
