QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#323219#44. Pathsjames1BadCreeper100 ✓224ms95840kbC++14912b2024-02-08 22:22:032024-02-08 22:22:05

Judging History

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

  • [2024-02-08 22:22:05]
  • 评测
  • 测评结果:100
  • 用时:224ms
  • 内存:95840kb
  • [2024-02-08 22:22:03]
  • 提交

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: 12324kb

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: 0
Accepted
time: 0ms
memory: 12512kb

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: 0
Accepted
time: 3ms
memory: 11836kb

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: 0
Accepted
time: 3ms
memory: 12512kb

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: 0
Accepted
time: 3ms
memory: 11840kb

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: 0
Accepted
time: 2ms
memory: 11756kb

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: 0
Accepted
time: 0ms
memory: 12524kb

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: 0
Accepted
time: 0ms
memory: 11820kb

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: 0
Accepted
time: 0ms
memory: 11828kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #10:

score: 0
Accepted
time: 3ms
memory: 11872kb

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: 31ms
memory: 17568kb

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: 0
Accepted
time: 30ms
memory: 15988kb

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: 0
Accepted
time: 157ms
memory: 95136kb

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: 0
Accepted
time: 58ms
memory: 24620kb

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: 0
Accepted
time: 58ms
memory: 24600kb

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: 0
Accepted
time: 126ms
memory: 69540kb

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: 0
Accepted
time: 167ms
memory: 95128kb

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: 0
Accepted
time: 142ms
memory: 95764kb

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: 42ms
memory: 18088kb

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: 0
Accepted
time: 34ms
memory: 16040kb

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: 0
Accepted
time: 153ms
memory: 95108kb

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: 0
Accepted
time: 61ms
memory: 24756kb

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: 0
Accepted
time: 52ms
memory: 25112kb

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: 0
Accepted
time: 108ms
memory: 68420kb

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: 0
Accepted
time: 142ms
memory: 95132kb

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: 0
Accepted
time: 142ms
memory: 95840kb

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: 0
Accepted
time: 37ms
memory: 16024kb

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: 0
Accepted
time: 45ms
memory: 19032kb

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: 0
Accepted
time: 224ms
memory: 95184kb

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: 0
Accepted
time: 138ms
memory: 55928kb

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: 0
Accepted
time: 128ms
memory: 54868kb

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: 0
Accepted
time: 224ms
memory: 95184kb

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: 0
Accepted
time: 2ms
memory: 11836kb

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: 0
Accepted
time: 3ms
memory: 12436kb

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: 0
Accepted
time: 0ms
memory: 11772kb

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: 0
Accepted
time: 3ms
memory: 12536kb

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: 0
Accepted
time: 3ms
memory: 11816kb

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: 0
Accepted
time: 0ms
memory: 12192kb

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: 0
Accepted
time: 0ms
memory: 12288kb

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: 0
Accepted
time: 0ms
memory: 11788kb

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: 0
Accepted
time: 2ms
memory: 11936kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #42:

score: 0
Accepted
time: 2ms
memory: 12264kb

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: 2ms
memory: 11820kb

input:

2 1 5
5 3
1 2

output:

2

result:

ok single line: '2'

Test #44:

score: 0
Accepted
time: 15ms
memory: 12592kb

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: 0
Accepted
time: 63ms
memory: 40484kb

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: 0
Accepted
time: 13ms
memory: 12792kb

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: 0
Accepted
time: 34ms
memory: 39848kb

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: 0
Accepted
time: 23ms
memory: 39984kb

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: 0
Accepted
time: 44ms
memory: 26172kb

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: 0
Accepted
time: 9ms
memory: 12748kb

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: 0
Accepted
time: 51ms
memory: 40856kb

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: 0
Accepted
time: 41ms
memory: 40192kb

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: 0
Accepted
time: 48ms
memory: 40252kb

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: 0
Accepted
time: 55ms
memory: 33284kb

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: 0
Accepted
time: 44ms
memory: 28088kb

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: 0
Accepted
time: 68ms
memory: 41708kb

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: 0
Accepted
time: 72ms
memory: 39992kb

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: 0
Accepted
time: 3ms
memory: 12612kb

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: 0
Accepted
time: 2ms
memory: 12412kb

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: 0
Accepted
time: 0ms
memory: 11904kb

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: 0
Accepted
time: 2ms
memory: 12040kb

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: 0
Accepted
time: 2ms
memory: 11936kb

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: 0
Accepted
time: 2ms
memory: 11796kb

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: 0
Accepted
time: 2ms
memory: 11828kb

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: 0
Accepted
time: 0ms
memory: 11996kb

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: 0
Accepted
time: 2ms
memory: 11760kb

input:

2 1 4
1 3
1 2

output:

2

result:

ok single line: '2'

Test #67:

score: 0
Accepted
time: 2ms
memory: 11888kb

input:

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

output:

12

result:

ok single line: '12'