QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#700797#44. PathsTheZone100 ✓191ms95824kbC++23912b2024-11-02 13:24:162024-11-02 13:24:17

Judging History

你现在查看的是最新测评结果

  • [2024-11-02 13:24:17]
  • 评测
  • 测评结果:100
  • 用时:191ms
  • 内存:95824kb
  • [2024-11-02 13:24:16]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64; 
const int N = 3e5 + 5; 

int n, m, k, a[N]; 
vector<int> G[N]; 
i64 f[N][1 << 5]; 

int main(void) {
    ios::sync_with_stdio(0); 
    cin >> n >> m >> k; 
    for (int i = 1; i <= n; ++i) cin >> a[i]; 
    while (m--) {
        int x, y; cin >> x >> y; 
        G[x].emplace_back(y); G[y].emplace_back(x); 
    }
    for (int i = 1; i < 1 << k; ++i) {
        if (i == (i & -i)) {
            for (int x = 1; x <= n; ++x)
                if (1 << a[x] - 1 == i) f[x][i] = 1; 
            continue; 
        }
        for (int x = 1; x <= n; ++x) if (i >> a[x] - 1)
            for (int y : G[x]) f[x][i] += f[y][i ^ (1 << a[x] - 1)]; 
    }
    i64 ans = 0; 
    for (int i = 1; i < 1 << k; ++i) if (i != (i & -i))
        for (int x = 1; x <= n; ++x) ans += f[x][i]; 
    cout << ans << '\n'; 
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 23
Accepted

Test #1:

score: 23
Accepted
time: 0ms
memory: 3688kb

input:

30 100 4
3 3 1 3 3 1 4 4 4 3 3 3 3 2 1 2 1 4 2 2 1 2 2 3 3 2 3 3 4 2
7 21
1 16
4 13
2 12
13 20
1 12
26 28
2 20
30 26
3 8
21 1
5 7
15 17
3 24
16 6
16 12
9 28
26 7
1 18
12 5
9 3
11 5
20 10
27 20
3 25
14 20
8 11
3 23
7 10
29 27
23 10
9 7
26 4
24 30
14 29
1 22
18 8
16 17
18 24
20 9
20 3
23 21
4 6
16 13
...

output:

1316

result:

ok single line: '1316'

Test #2:

score: 23
Accepted
time: 1ms
memory: 3780kb

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #3:

score: 23
Accepted
time: 1ms
memory: 3628kb

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #4:

score: 23
Accepted
time: 1ms
memory: 5676kb

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #5:

score: 23
Accepted
time: 1ms
memory: 5792kb

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #6:

score: 23
Accepted
time: 1ms
memory: 3656kb

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #7:

score: 23
Accepted
time: 0ms
memory: 3760kb

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #8:

score: 23
Accepted
time: 1ms
memory: 5768kb

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #9:

score: 23
Accepted
time: 1ms
memory: 3680kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #10:

score: 23
Accepted
time: 1ms
memory: 3620kb

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'

Subtask #2:

score: 20
Accepted

Test #11:

score: 20
Accepted
time: 39ms
memory: 8728kb

input:

5000 300000 3
3 1 3 3 3 1 3 2 2 1 3 3 1 2 3 3 3 1 2 3 2 3 2 3 3 1 3 3 2 2 1 2 1 2 1 1 1 3 3 3 1 2 3 3 1 3 2 2 2 1 1 3 1 3 3 1 2 3 3 2 1 2 1 2 1 3 3 3 3 3 1 3 1 2 3 2 2 3 2 1 2 2 2 2 1 3 2 2 3 3 3 1 1 2 3 2 1 1 2 2 1 1 2 2 1 3 3 1 1 2 3 1 2 3 3 3 2 2 2 3 1 3 2 3 1 3 2 3 3 3 1 2 3 3 3 2 2 2 3 3 3 1 3 ...

output:

16436298

result:

ok single line: '16436298'

Test #12:

score: 20
Accepted
time: 31ms
memory: 9296kb

input:

800 300000 3
2 3 1 2 3 1 1 1 1 3 2 1 2 3 2 2 3 3 3 3 2 2 3 3 2 2 1 2 3 2 3 1 2 1 3 3 3 1 2 2 1 1 1 2 3 3 3 2 2 1 1 3 3 3 1 2 2 3 1 3 1 1 1 3 3 1 2 1 1 3 3 2 2 2 2 3 2 2 3 2 1 1 2 3 1 3 2 2 3 3 2 2 2 3 2 1 1 3 3 3 1 1 3 2 2 1 3 1 2 3 1 3 1 1 1 1 1 2 3 3 2 2 3 3 2 1 3 3 3 1 1 1 3 3 1 1 2 2 3 2 1 2 3 3...

output:

100589586

result:

ok single line: '100589586'

Test #13:

score: 20
Accepted
time: 126ms
memory: 95208kb

input:

300000 300000 3
2 3 3 2 3 3 2 2 2 2 3 1 3 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 3 3 2 1 1 2 3 1 2 3 2 2 3 1 1 3 1 2 2 2 2 1 2 2 1 1 2 2 2 3 2 2 1 1 3 3 2 1 1 1 3 1 1 3 3 2 2 3 3 1 2 2 2 1 2 1 2 2 3 1 2 3 1 2 2 2 3 2 1 3 1 1 1 3 3 2 3 2 3 3 3 3 1 1 2 2 3 1 1 1 3 2 1 1 2 1 2 1 3 3 2 1 1 1 2 2 2 2 1 1 1 1 2 2 ...

output:

665606

result:

ok single line: '665606'

Test #14:

score: 20
Accepted
time: 57ms
memory: 20336kb

input:

30000 300000 2
2 2 1 2 1 2 2 1 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2...

output:

299694

result:

ok single line: '299694'

Test #15:

score: 20
Accepted
time: 46ms
memory: 20104kb

input:

30000 300000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok single line: '0'

Test #16:

score: 20
Accepted
time: 89ms
memory: 69068kb

input:

200000 299999 3
3 3 1 1 2 1 1 2 2 2 2 3 1 3 1 2 2 3 3 2 2 3 2 1 1 1 3 3 2 1 1 2 2 1 2 3 2 3 1 3 3 3 1 2 1 1 3 3 1 1 2 2 1 2 2 3 1 3 2 3 1 2 3 3 3 1 2 2 1 1 1 2 1 3 1 1 3 1 3 3 3 2 1 2 2 3 3 3 1 1 2 2 2 2 2 1 2 2 2 1 3 1 3 1 3 1 2 1 2 3 1 1 2 1 1 1 3 1 3 1 3 3 1 3 1 1 1 2 1 2 2 1 3 3 3 3 3 2 2 1 3 3 ...

output:

8922060294

result:

ok single line: '8922060294'

Test #17:

score: 20
Accepted
time: 127ms
memory: 95248kb

input:

300000 300000 3
3 2 2 1 1 2 3 1 3 2 2 3 3 2 3 2 2 2 2 3 3 1 1 1 1 1 2 3 1 1 3 2 1 3 1 2 1 3 1 1 2 3 2 2 2 3 1 2 1 3 1 3 3 3 2 2 2 1 1 2 2 3 3 3 3 2 1 1 2 1 1 1 1 2 3 2 2 1 2 2 3 1 3 2 2 3 3 2 3 2 2 1 2 2 2 1 1 1 3 3 3 2 1 3 1 1 2 3 3 1 2 1 2 3 3 3 2 2 1 3 1 3 1 1 2 1 2 1 1 1 3 1 1 3 1 2 1 1 2 1 1 3 ...

output:

666528

result:

ok single line: '666528'

Test #18:

score: 20
Accepted
time: 119ms
memory: 95816kb

input:

300000 300000 3
1 3 1 1 2 1 1 1 3 1 2 3 1 3 1 2 2 3 1 3 1 2 2 2 1 3 3 3 2 1 3 3 2 1 2 2 3 1 2 3 1 3 1 3 1 1 1 3 3 2 3 3 2 1 2 1 3 2 2 1 2 2 2 1 2 2 2 2 1 1 2 1 1 3 2 1 1 1 3 1 3 3 2 1 3 3 3 1 3 3 1 2 1 2 3 1 1 2 1 2 3 2 3 1 1 1 1 3 2 1 2 3 2 3 2 2 3 3 3 3 1 3 2 3 3 1 3 1 2 3 2 2 2 1 1 2 3 3 2 3 3 2 ...

output:

577020

result:

ok single line: '577020'

Subtask #3:

score: 27
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #19:

score: 27
Accepted
time: 41ms
memory: 11828kb

input:

5000 300000 3
3 1 3 3 3 1 3 2 2 1 3 3 1 2 3 3 3 1 2 3 2 3 2 3 3 1 3 3 2 2 1 2 1 2 1 1 1 3 3 3 1 2 3 3 1 3 2 2 2 1 1 3 1 3 3 1 2 3 3 2 1 2 1 2 1 3 3 3 3 3 1 3 1 2 3 2 2 3 2 1 2 2 2 2 1 3 2 2 3 3 3 1 1 2 3 2 1 1 2 2 1 1 2 2 1 3 3 1 1 2 3 1 2 3 3 3 2 2 2 3 1 3 2 3 1 3 2 3 3 3 1 2 3 3 3 2 2 2 3 3 3 1 3 ...

output:

16436298

result:

ok single line: '16436298'

Test #20:

score: 27
Accepted
time: 30ms
memory: 7184kb

input:

800 300000 3
2 3 1 2 3 1 1 1 1 3 2 1 2 3 2 2 3 3 3 3 2 2 3 3 2 2 1 2 3 2 3 1 2 1 3 3 3 1 2 2 1 1 1 2 3 3 3 2 2 1 1 3 3 3 1 2 2 3 1 3 1 1 1 3 3 1 2 1 1 3 3 2 2 2 2 3 2 2 3 2 1 1 2 3 1 3 2 2 3 3 2 2 2 3 2 1 1 3 3 3 1 1 3 2 2 1 3 1 2 3 1 3 1 1 1 1 1 2 3 3 2 2 3 3 2 1 3 3 3 1 1 1 3 3 1 1 2 2 3 2 1 2 3 3...

output:

100589586

result:

ok single line: '100589586'

Test #21:

score: 27
Accepted
time: 126ms
memory: 95252kb

input:

300000 300000 3
2 3 3 2 3 3 2 2 2 2 3 1 3 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 3 3 2 1 1 2 3 1 2 3 2 2 3 1 1 3 1 2 2 2 2 1 2 2 1 1 2 2 2 3 2 2 1 1 3 3 2 1 1 1 3 1 1 3 3 2 2 3 3 1 2 2 2 1 2 1 2 2 3 1 2 3 1 2 2 2 3 2 1 3 1 1 1 3 3 2 3 2 3 3 3 3 1 1 2 2 3 1 1 1 3 2 1 1 2 1 2 1 3 3 2 1 1 1 2 2 2 2 1 1 1 1 2 2 ...

output:

665606

result:

ok single line: '665606'

Test #22:

score: 27
Accepted
time: 59ms
memory: 20152kb

input:

30000 300000 2
2 2 1 2 1 2 2 1 2 1 1 2 2 1 2 2 2 2 2 2 1 2 2 1 1 2 1 1 1 2 2 1 2 1 2 1 2 2 1 2 1 2 1 1 2 1 2 2 1 1 1 2 1 2 1 1 1 1 2 1 2 2 2 1 2 1 2 2 1 1 2 2 2 2 1 1 1 2 1 1 2 1 2 2 1 2 2 1 1 2 1 2 2 2 2 1 2 2 2 1 2 2 2 2 2 1 2 2 1 1 1 1 2 1 1 2 2 2 1 2 2 2 1 1 2 2 2 2 1 1 2 1 2 2 2 1 1 1 2 1 2 1 2...

output:

299694

result:

ok single line: '299694'

Test #23:

score: 27
Accepted
time: 58ms
memory: 19640kb

input:

30000 300000 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok single line: '0'

Test #24:

score: 27
Accepted
time: 98ms
memory: 66596kb

input:

200000 299999 3
3 3 1 1 2 1 1 2 2 2 2 3 1 3 1 2 2 3 3 2 2 3 2 1 1 1 3 3 2 1 1 2 2 1 2 3 2 3 1 3 3 3 1 2 1 1 3 3 1 1 2 2 1 2 2 3 1 3 2 3 1 2 3 3 3 1 2 2 1 1 1 2 1 3 1 1 3 1 3 3 3 2 1 2 2 3 3 3 1 1 2 2 2 2 2 1 2 2 2 1 3 1 3 1 3 1 2 1 2 3 1 1 2 1 1 1 3 1 3 1 3 3 1 3 1 1 1 2 1 2 2 1 3 3 3 3 3 2 2 1 3 3 ...

output:

8922060294

result:

ok single line: '8922060294'

Test #25:

score: 27
Accepted
time: 151ms
memory: 95224kb

input:

300000 300000 3
3 2 2 1 1 2 3 1 3 2 2 3 3 2 3 2 2 2 2 3 3 1 1 1 1 1 2 3 1 1 3 2 1 3 1 2 1 3 1 1 2 3 2 2 2 3 1 2 1 3 1 3 3 3 2 2 2 1 1 2 2 3 3 3 3 2 1 1 2 1 1 1 1 2 3 2 2 1 2 2 3 1 3 2 2 3 3 2 3 2 2 1 2 2 2 1 1 1 3 3 3 2 1 3 1 1 2 3 3 1 2 1 2 3 3 3 2 2 1 3 1 3 1 1 2 1 2 1 1 1 3 1 1 3 1 2 1 1 2 1 1 3 ...

output:

666528

result:

ok single line: '666528'

Test #26:

score: 27
Accepted
time: 124ms
memory: 95824kb

input:

300000 300000 3
1 3 1 1 2 1 1 1 3 1 2 3 1 3 1 2 2 3 1 3 1 2 2 2 1 3 3 3 2 1 3 3 2 1 2 2 3 1 2 3 1 3 1 3 1 1 1 3 3 2 3 3 2 1 2 1 3 2 2 1 2 2 2 1 2 2 2 2 1 1 2 1 1 3 2 1 1 1 3 1 3 3 2 1 3 3 3 1 3 3 1 2 1 2 3 1 1 2 1 2 3 2 3 1 1 1 1 3 2 1 2 3 2 3 2 2 3 3 3 3 1 3 2 3 3 1 3 1 2 3 2 2 2 1 1 2 3 3 2 3 3 2 ...

output:

577020

result:

ok single line: '577020'

Test #27:

score: 27
Accepted
time: 30ms
memory: 9244kb

input:

800 300000 4
3 2 4 4 1 4 1 3 2 4 3 2 3 1 2 3 2 2 2 2 4 1 4 3 4 2 2 4 1 2 1 3 2 2 2 1 4 3 4 2 1 1 1 2 3 1 2 4 3 1 4 3 2 1 1 4 1 4 1 1 3 3 2 2 1 2 3 2 4 4 4 4 1 3 2 3 3 3 4 3 4 2 2 3 4 4 1 3 1 4 2 2 4 4 1 3 3 2 4 1 1 1 1 3 4 2 3 1 2 3 2 3 4 2 4 2 1 4 2 4 3 1 4 4 4 4 2 1 2 2 2 4 3 2 3 3 2 1 3 1 4 1 4 4...

output:

31899888672

result:

ok single line: '31899888672'

Test #28:

score: 27
Accepted
time: 46ms
memory: 12432kb

input:

8000 300000 4
1 4 1 4 2 2 4 2 1 1 1 4 3 4 2 3 1 3 4 3 2 1 4 3 3 4 4 2 2 3 2 1 4 4 4 1 3 4 1 4 3 1 3 1 1 3 3 1 3 3 2 3 4 1 2 1 1 4 4 4 4 2 3 4 3 2 1 4 3 2 2 4 4 3 2 2 4 3 1 3 2 3 4 3 2 3 4 3 1 2 4 1 1 2 1 1 3 2 3 2 4 3 3 3 2 2 2 1 4 2 2 2 3 4 4 3 2 1 1 4 2 3 1 1 4 3 4 2 1 2 2 1 2 3 3 2 4 2 3 3 4 2 4 ...

output:

334222370

result:

ok single line: '334222370'

Test #29:

score: 27
Accepted
time: 191ms
memory: 95248kb

input:

300000 300000 4
1 3 3 3 4 4 3 3 3 2 1 2 2 1 4 3 3 1 3 2 4 2 1 2 4 3 2 2 4 3 3 4 1 3 2 4 3 3 4 2 2 2 4 2 4 1 4 3 1 1 2 4 2 2 2 3 2 2 2 2 1 3 2 4 4 1 2 2 2 4 3 2 4 1 3 3 4 1 3 4 1 4 2 2 4 2 2 2 1 3 3 3 1 3 4 1 1 1 3 3 3 4 2 3 1 3 2 3 3 2 4 2 1 4 2 2 3 2 2 3 4 3 4 2 2 4 3 4 4 1 3 4 2 4 1 1 2 3 2 1 3 3 ...

output:

1121790

result:

ok single line: '1121790'

Test #30:

score: 27
Accepted
time: 105ms
memory: 51512kb

input:

150000 299999 4
3 4 2 3 4 3 3 3 1 4 4 1 4 2 1 3 4 2 3 4 3 2 3 3 2 3 3 2 3 2 3 1 2 1 4 2 2 2 3 4 1 3 1 3 2 4 4 1 4 1 2 1 1 4 4 3 1 4 4 1 4 3 3 4 1 4 3 3 1 2 1 4 1 4 1 2 1 4 4 3 3 3 4 1 1 1 3 4 1 4 2 4 4 1 3 2 1 3 3 1 3 4 2 3 4 4 3 2 3 3 3 1 3 4 1 3 4 3 4 2 4 4 3 3 1 3 1 3 2 2 3 3 3 4 4 2 4 1 4 3 3 1 ...

output:

16831953826

result:

ok single line: '16831953826'

Test #31:

score: 27
Accepted
time: 108ms
memory: 52872kb

input:

150000 299999 4
3 4 4 3 4 3 4 2 2 2 4 4 3 3 3 2 3 4 2 3 3 3 3 2 4 2 3 3 2 2 4 3 3 2 3 4 4 4 4 4 4 2 2 2 4 3 2 4 4 2 3 4 3 3 4 2 3 3 4 4 2 3 2 4 2 3 2 4 4 4 3 3 2 4 3 3 2 4 4 2 4 3 4 2 3 4 2 4 4 3 3 2 4 3 4 4 4 4 4 2 3 3 4 3 3 3 3 2 4 4 3 2 4 3 4 2 2 4 3 3 2 3 3 3 4 2 2 3 3 4 3 4 3 4 2 2 3 3 2 4 2 3 ...

output:

16660046632

result:

ok single line: '16660046632'

Test #32:

score: 27
Accepted
time: 185ms
memory: 95220kb

input:

300000 300000 4
4 2 3 2 4 4 2 3 3 4 4 4 2 3 2 4 4 4 2 1 3 2 1 2 4 4 2 3 3 2 4 3 3 2 1 2 1 3 2 2 4 4 1 1 1 1 4 2 4 3 3 4 1 2 4 4 4 4 1 1 1 3 4 4 2 1 2 4 4 4 4 3 4 4 2 4 4 1 1 1 3 3 3 2 2 4 4 2 1 3 2 2 1 3 3 2 4 1 1 3 2 2 4 1 4 4 4 2 2 3 1 2 1 3 3 4 3 4 4 3 3 2 1 3 2 4 3 1 4 2 1 4 4 2 3 4 4 4 1 3 1 2 ...

output:

1126130

result:

ok single line: '1126130'

Test #33:

score: 27
Accepted
time: 0ms
memory: 5680kb

input:

30 100 4
3 3 1 3 3 1 4 4 4 3 3 3 3 2 1 2 1 4 2 2 1 2 2 3 3 2 3 3 4 2
7 21
1 16
4 13
2 12
13 20
1 12
26 28
2 20
30 26
3 8
21 1
5 7
15 17
3 24
16 6
16 12
9 28
26 7
1 18
12 5
9 3
11 5
20 10
27 20
3 25
14 20
8 11
3 23
7 10
29 27
23 10
9 7
26 4
24 30
14 29
1 22
18 8
16 17
18 24
20 9
20 3
23 21
4 6
16 13
...

output:

1316

result:

ok single line: '1316'

Test #34:

score: 27
Accepted
time: 1ms
memory: 3648kb

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #35:

score: 27
Accepted
time: 1ms
memory: 5736kb

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #36:

score: 27
Accepted
time: 1ms
memory: 5792kb

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #37:

score: 27
Accepted
time: 1ms
memory: 5804kb

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #38:

score: 27
Accepted
time: 1ms
memory: 3712kb

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #39:

score: 27
Accepted
time: 1ms
memory: 3632kb

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #40:

score: 27
Accepted
time: 1ms
memory: 5744kb

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #41:

score: 27
Accepted
time: 1ms
memory: 5716kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #42:

score: 27
Accepted
time: 1ms
memory: 5740kb

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'

Subtask #4:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #43:

score: 30
Accepted
time: 1ms
memory: 3560kb

input:

2 1 5
5 3
1 2

output:

2

result:

ok single line: '2'

Test #44:

score: 30
Accepted
time: 10ms
memory: 4600kb

input:

480 100000 5
2 2 2 3 5 2 1 5 3 5 5 2 4 2 3 3 3 1 2 3 4 2 4 3 5 5 4 4 2 4 4 2 5 1 2 1 1 1 2 2 2 5 1 3 5 1 1 2 3 5 4 4 4 1 1 4 4 3 1 3 3 1 5 3 3 3 2 1 5 3 5 4 2 5 2 3 5 5 3 3 3 2 5 3 2 3 5 5 3 2 3 5 1 5 2 5 2 1 1 3 4 2 5 4 4 2 1 1 5 5 4 1 2 4 4 1 5 2 3 3 3 1 5 3 2 4 3 4 3 2 3 1 2 3 5 3 5 4 5 3 5 3 1 1...

output:

545258011824

result:

ok single line: '545258011824'

Test #45:

score: 30
Accepted
time: 56ms
memory: 35996kb

input:

100000 100000 5
4 2 3 3 5 1 2 5 5 5 1 3 4 5 2 3 2 3 4 2 2 4 4 5 1 3 3 5 5 1 2 5 5 5 5 3 3 4 5 1 2 3 4 4 5 4 2 5 3 2 4 3 4 5 2 2 1 2 5 5 4 1 5 4 4 5 5 3 4 5 3 2 2 4 5 4 3 4 2 4 2 4 4 5 3 3 4 5 3 2 5 1 4 5 4 4 4 4 5 5 3 1 5 1 4 5 2 3 5 2 4 1 2 4 1 1 3 3 3 3 5 5 1 1 2 2 1 2 5 4 5 2 3 1 5 4 2 3 1 4 3 2 ...

output:

564534

result:

ok single line: '564534'

Test #46:

score: 30
Accepted
time: 8ms
memory: 6720kb

input:

480 100000 3
3 2 3 3 2 2 1 1 3 2 2 1 2 1 1 2 1 2 1 3 1 1 3 1 2 2 2 2 3 1 2 2 1 2 1 3 1 3 2 2 1 2 2 3 3 1 2 1 3 1 1 3 2 1 3 2 2 3 1 3 2 3 3 2 3 1 1 1 1 3 2 2 2 3 2 2 3 2 3 3 1 1 3 3 1 3 2 3 1 3 3 2 3 1 1 3 2 2 3 1 1 2 2 2 3 1 1 1 2 3 1 3 2 2 2 1 1 2 1 1 1 3 1 2 1 1 2 3 3 3 3 1 1 2 3 3 3 3 2 3 2 3 3 2...

output:

18770760

result:

ok single line: '18770760'

Test #47:

score: 30
Accepted
time: 31ms
memory: 35604kb

input:

100000 100000 3
2 3 2 2 1 2 2 1 1 2 2 1 2 3 1 3 1 2 1 3 2 3 3 2 3 1 2 3 1 2 1 3 3 2 2 3 2 2 2 3 2 2 2 3 2 1 2 2 3 2 2 2 2 3 3 2 2 2 2 3 2 3 2 3 2 3 1 3 1 2 3 3 3 1 2 2 2 2 2 3 1 1 1 2 1 1 3 1 3 2 2 2 1 2 2 2 1 1 2 3 2 1 3 1 3 2 1 2 3 2 2 1 1 3 2 3 1 3 3 3 2 1 1 2 3 1 1 3 1 2 2 3 2 1 3 2 2 3 1 3 2 2 ...

output:

222836

result:

ok single line: '222836'

Test #48:

score: 30
Accepted
time: 26ms
memory: 35604kb

input:

100000 99999 3
1 2 2 2 3 1 1 3 1 2 1 1 2 2 2 3 3 1 1 1 1 2 2 3 1 1 1 2 2 2 3 1 2 1 3 1 3 3 2 2 2 2 2 1 2 2 2 2 1 2 3 3 3 1 3 3 3 1 3 2 1 1 2 1 3 3 1 3 3 2 1 1 3 1 1 1 3 2 3 2 1 3 1 3 1 1 1 1 1 3 3 2 3 2 1 3 2 3 3 2 2 2 1 3 1 2 3 2 2 2 1 3 1 2 1 3 3 3 1 3 1 3 3 2 3 1 3 1 3 2 2 2 2 1 1 3 1 2 2 1 3 2 2...

output:

2220366454

result:

ok single line: '2220366454'

Test #49:

score: 30
Accepted
time: 44ms
memory: 20404kb

input:

50000 89999 5
5 3 5 4 1 3 2 3 3 2 5 5 5 5 3 3 3 3 2 1 4 5 3 2 2 1 1 2 2 1 1 3 5 1 5 1 3 2 1 3 1 1 3 1 3 1 3 4 4 5 4 2 1 1 2 4 2 3 4 4 2 1 5 2 2 5 3 3 1 5 2 1 3 3 4 4 1 3 4 4 1 4 4 5 4 1 2 4 1 4 1 3 4 3 5 1 3 2 5 2 3 3 2 4 3 3 1 1 1 4 3 4 2 1 5 5 3 1 1 5 4 2 3 4 5 1 5 3 3 4 1 2 4 1 3 1 4 4 2 3 5 1 4 ...

output:

3454818410

result:

ok single line: '3454818410'

Test #50:

score: 30
Accepted
time: 8ms
memory: 6756kb

input:

480 100000 4
3 2 4 1 4 2 3 4 4 4 2 4 4 1 3 1 1 4 3 3 1 3 3 1 1 3 1 1 2 4 2 4 1 1 2 2 4 3 1 2 2 4 1 1 3 2 3 1 3 4 3 1 3 4 3 4 3 3 4 3 1 3 1 4 3 3 2 3 4 3 3 3 4 3 2 1 2 4 2 2 1 1 3 4 2 2 4 2 2 1 1 3 4 4 3 2 3 1 4 3 2 1 2 2 1 3 1 1 2 3 3 2 2 4 1 2 2 2 4 1 4 1 3 1 4 2 3 4 3 4 2 4 1 3 3 4 3 3 3 4 3 4 4 3...

output:

3277553092

result:

ok single line: '3277553092'

Test #51:

score: 30
Accepted
time: 42ms
memory: 35720kb

input:

100000 100000 4
1 1 1 1 3 3 4 1 4 4 2 3 1 1 2 4 4 1 3 1 4 3 2 2 2 3 3 4 3 4 3 2 4 2 1 1 3 3 4 4 1 4 1 2 3 1 1 4 4 2 4 2 1 4 4 2 1 1 2 2 2 3 3 1 1 3 4 3 4 1 1 3 4 1 4 2 1 1 3 4 3 4 1 3 1 2 3 4 2 1 4 4 2 2 1 3 2 2 3 4 4 3 1 4 2 1 2 2 4 4 2 3 3 4 3 2 1 4 4 3 3 2 3 3 2 1 1 1 4 2 1 4 1 4 3 4 3 4 1 3 2 4 ...

output:

374134

result:

ok single line: '374134'

Test #52:

score: 30
Accepted
time: 37ms
memory: 36568kb

input:

100000 99999 4
3 2 3 2 4 3 3 3 1 1 1 1 4 2 4 2 2 1 2 4 1 1 4 2 1 1 4 3 1 3 3 3 4 2 4 1 1 3 2 2 3 3 3 3 3 3 1 2 1 2 4 4 4 1 3 1 1 4 3 3 4 3 4 3 3 3 2 4 1 4 2 4 2 3 2 3 4 2 1 1 4 3 3 1 1 3 3 4 2 1 3 2 3 4 4 2 1 2 1 1 4 2 4 1 4 4 4 1 4 1 4 3 4 4 1 3 4 2 2 3 1 1 3 1 3 2 1 1 2 3 1 2 3 3 4 2 3 4 3 2 1 1 2...

output:

3760223314

result:

ok single line: '3760223314'

Test #53:

score: 30
Accepted
time: 39ms
memory: 36836kb

input:

100000 99999 4
2 4 2 3 3 4 2 4 3 2 2 2 3 3 3 2 4 2 2 2 4 4 4 4 4 2 3 3 4 4 4 4 3 4 4 2 4 2 3 4 4 2 4 2 2 4 3 2 4 4 3 3 3 3 3 3 3 3 3 3 4 3 2 4 2 3 2 2 4 2 3 4 4 2 2 2 4 4 2 2 4 4 2 2 2 3 3 3 3 2 3 4 4 2 3 3 4 2 3 3 4 4 4 4 2 3 2 2 2 2 4 3 3 4 4 3 3 4 4 4 2 2 3 3 3 4 2 2 2 2 3 3 2 4 2 2 2 3 3 4 4 4 4...

output:

4444622220

result:

ok single line: '4444622220'

Test #54:

score: 30
Accepted
time: 52ms
memory: 29416kb

input:

75000 99996 5
1 5 3 3 3 3 5 5 5 3 3 1 1 5 3 3 5 1 5 5 5 5 1 1 3 1 3 3 1 3 5 1 3 3 3 3 3 5 5 3 3 1 3 1 1 3 1 5 3 3 3 5 5 5 3 1 5 3 3 3 5 1 5 3 5 1 3 5 1 5 3 3 5 5 5 1 1 5 3 1 1 5 3 5 3 1 3 3 1 5 1 1 3 3 3 1 3 5 3 3 1 1 5 3 3 5 3 3 1 1 1 1 5 1 5 5 1 5 3 5 1 5 1 1 1 1 5 5 3 3 1 5 1 5 3 5 3 1 1 1 3 1 1 ...

output:

31252499849988

result:

ok single line: '31252499849988'

Test #55:

score: 30
Accepted
time: 40ms
memory: 20364kb

input:

50000 96664 5
4 5 1 4 1 4 5 1 1 4 1 5 4 5 1 1 4 4 4 4 1 4 1 1 4 1 4 5 1 5 5 4 5 5 4 5 4 4 1 4 5 5 4 4 4 5 5 1 4 1 5 1 4 5 4 4 5 1 1 4 5 5 4 5 4 5 1 5 4 5 5 1 4 5 1 4 5 1 4 1 1 1 4 1 5 1 5 4 1 5 1 4 1 5 5 1 4 5 1 5 1 1 5 1 5 1 1 4 4 4 5 1 1 4 4 1 1 5 1 5 1 1 1 4 1 4 5 1 1 5 5 4 4 5 4 4 5 5 1 1 4 4 4 ...

output:

9262597908028

result:

ok single line: '9262597908028'

Test #56:

score: 30
Accepted
time: 68ms
memory: 35104kb

input:

100000 100000 5
5 1 5 1 4 4 4 4 4 5 1 2 4 3 4 5 5 4 2 3 3 5 4 3 5 1 3 1 3 1 3 5 2 2 5 3 1 1 1 1 2 4 3 5 3 4 2 4 5 1 2 5 3 4 5 5 1 2 2 5 4 5 5 4 2 5 1 2 2 3 3 4 3 5 4 2 4 4 2 4 5 1 1 2 4 3 2 3 4 1 5 3 1 4 4 4 3 2 3 3 1 5 1 3 4 3 1 1 2 2 2 1 2 2 4 4 3 2 3 1 2 3 2 5 2 4 1 4 3 2 2 2 2 5 3 3 5 3 5 3 2 4 ...

output:

559300

result:

ok single line: '559300'

Test #57:

score: 30
Accepted
time: 65ms
memory: 38088kb

input:

100000 100000 5
1 2 2 3 2 3 5 1 4 3 4 4 2 1 4 5 2 4 2 5 5 3 5 3 3 3 4 2 5 1 5 2 1 5 5 4 2 3 3 5 2 5 4 1 1 4 1 2 3 2 5 2 3 4 3 3 4 1 5 4 4 3 5 4 4 3 3 2 4 1 3 4 4 4 3 1 5 2 1 1 1 4 2 2 5 5 2 3 5 1 2 2 4 1 1 2 5 2 1 3 5 5 1 4 3 2 1 5 4 2 5 2 3 2 2 3 2 2 3 1 4 3 1 4 4 1 5 2 3 4 2 5 2 2 3 5 5 1 2 2 1 1 ...

output:

398058

result:

ok single line: '398058'

Test #58:

score: 30
Accepted
time: 1ms
memory: 3624kb

input:

30 100 4
3 3 1 3 3 1 4 4 4 3 3 3 3 2 1 2 1 4 2 2 1 2 2 3 3 2 3 3 4 2
7 21
1 16
4 13
2 12
13 20
1 12
26 28
2 20
30 26
3 8
21 1
5 7
15 17
3 24
16 6
16 12
9 28
26 7
1 18
12 5
9 3
11 5
20 10
27 20
3 25
14 20
8 11
3 23
7 10
29 27
23 10
9 7
26 4
24 30
14 29
1 22
18 8
16 17
18 24
20 9
20 3
23 21
4 6
16 13
...

output:

1316

result:

ok single line: '1316'

Test #59:

score: 30
Accepted
time: 0ms
memory: 3644kb

input:

100 100 4
1 2 1 2 2 3 2 4 1 2 3 2 2 3 1 4 1 3 2 3 4 4 2 3 1 4 3 4 1 4 2 4 1 3 4 2 2 1 1 2 3 2 2 3 4 2 4 1 4 2 1 1 2 2 3 1 2 4 1 4 2 2 4 3 3 2 4 1 3 1 2 3 3 4 1 2 4 3 4 2 1 1 4 4 4 3 1 1 4 2 3 3 2 4 4 2 2 2 1 1
57 14
39 28
36 49
9 35
17 12
74 16
65 34
69 29
95 16
72 85
27 85
68 45
85 76
49 99
46 31
7...

output:

404

result:

ok single line: '404'

Test #60:

score: 30
Accepted
time: 0ms
memory: 5672kb

input:

50 100 3
2 1 1 1 1 1 1 1 2 3 2 1 2 3 2 3 2 2 2 2 3 2 3 3 1 1 1 2 3 1 3 1 2 1 3 3 1 2 1 3 3 1 2 1 2 3 2 2 2 2
25 13
16 25
35 25
33 8
48 42
15 16
36 33
5 4
16 32
31 34
19 28
6 30
39 43
50 19
10 50
13 15
13 29
30 18
46 21
39 35
45 8
43 14
23 48
26 23
1 35
47 32
13 22
29 24
40 32
21 38
30 44
44 46
33 6
...

output:

348

result:

ok single line: '348'

Test #61:

score: 30
Accepted
time: 1ms
memory: 3748kb

input:

50 100 2
2 1 2 1 2 2 1 1 1 2 1 1 1 2 2 2 1 1 2 1 1 1 1 1 1 2 2 2 1 2 2 2 1 1 2 1 1 1 2 1 2 1 2 1 2 2 2 2 1 2
37 11
3 45
26 21
26 33
16 49
25 7
21 14
43 48
21 40
4 11
30 34
40 43
5 21
12 32
34 42
38 4
2 15
4 1
41 45
49 48
30 8
42 20
34 44
50 5
5 49
34 16
50 33
41 15
18 47
23 8
37 19
48 26
19 33
11 36...

output:

94

result:

ok single line: '94'

Test #62:

score: 30
Accepted
time: 1ms
memory: 5736kb

input:

50 100 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
41 25
26 50
33 20
38 35
22 25
14 50
12 15
20 19
23 8
44 50
22 42
9 50
39 21
26 20
44 23
24 31
12 28
23 49
25 14
43 37
2 24
8 19
26 11
43 5
9 18
47 22
9 28
50 27
30 5
22 28
7 6
48 18
37 47
15 ...

output:

0

result:

ok single line: '0'

Test #63:

score: 30
Accepted
time: 1ms
memory: 3712kb

input:

100 100 4
4 1 3 3 4 3 4 2 4 3 2 1 2 2 3 2 4 2 2 3 4 1 4 3 4 3 2 3 2 3 1 4 1 4 1 1 1 1 1 1 1 3 4 4 3 1 1 2 1 1 4 2 4 4 3 3 2 1 4 2 2 3 2 3 2 1 2 3 2 4 1 1 4 3 1 1 1 4 2 3 1 3 2 3 4 3 3 4 2 2 1 1 1 2 4 2 4 4 2 1
91 30
94 91
38 91
72 91
23 91
91 4
91 33
91 18
91 41
91 14
91 5
39 91
100 91
50 91
91 6
43...

output:

3598

result:

ok single line: '3598'

Test #64:

score: 30
Accepted
time: 1ms
memory: 3704kb

input:

60 99 4
3 2 1 2 3 1 2 3 3 1 3 1 1 1 2 1 3 1 2 2 1 2 1 3 1 1 3 2 3 3 3 3 3 2 1 2 1 2 3 2 2 3 2 2 3 1 1 2 1 1 2 2 2 1 3 1 3 3 4 3
59 27
21 57
4 59
28 40
47 18
45 59
40 59
17 59
59 32
32 7
12 17
44 59
41 59
59 51
57 35
54 43
50 60
37 8
53 17
25 55
28 51
59 28
35 27
38 59
9 59
28 60
6 42
36 59
11 51
26 ...

output:

2406

result:

ok single line: '2406'

Test #65:

score: 30
Accepted
time: 1ms
memory: 5752kb

input:

100 100 4
4 2 3 1 2 4 4 1 4 4 4 4 4 3 1 1 2 1 1 4 4 3 3 3 2 1 3 3 3 1 1 2 1 4 2 3 4 3 2 2 3 2 3 1 3 4 2 1 2 2 4 2 3 2 3 3 1 2 2 2 4 1 4 3 2 1 3 1 4 4 2 2 2 2 4 3 2 4 2 1 1 3 1 3 4 4 2 1 2 4 3 4 3 2 1 2 1 4 4 4
45 72
77 72
25 27
13 14
92 25
33 70
94 71
82 24
100 66
72 64
88 11
73 16
16 40
19 10
31 26...

output:

316

result:

ok single line: '316'

Test #66:

score: 30
Accepted
time: 1ms
memory: 3616kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #67:

score: 30
Accepted
time: 1ms
memory: 3668kb

input:

3 3 3
1 3 2
3 1
1 2
2 3

output:

12

result:

ok single line: '12'