QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#110058#2001. Tropical Gardenthenymphsofdelphi#100 ✓1539ms57308kbC++207.0kb2023-05-31 12:57:292024-05-31 13:52:19

Judging History

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

  • [2024-05-31 13:52:19]
  • 评测
  • 测评结果:100
  • 用时:1539ms
  • 内存:57308kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-31 12:57:29]
  • 提交

answer

#include "garden.h"
#include "gardenlib.h"

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = (l); i < (r); i++)
#define ForE(i, l, r) for (auto i = (l); i <= (r); i++)
#define FordE(i, l, r) for (auto i = (l); i >= (r); i--)
#define Fora(v, a) for (auto v: (a))
#define bend(a) (a).begin(), (a).end()
#define isz(a) ((signed)(a).size())

using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pii>;
using vvi = vector <vi>;

struct functional_graph_processor{
    functional_graph_processor(const vector<int> &next): n((int)next.size()), cycle_id(n, -1), cycle_pos(n, -1), root(n, -1), depth(n, -1), abr(n){
        vector<int> was(n);
        for(auto u = 0; u < n; ++ u){
            if(was[u]) continue;
            int v = u;
            while(!was[v]){
                was[v] = true;
                v = next[v];
            }
            if(!~depth[v]){
                int w = v;
                vector<int> c;
                while(!~depth[w]){
                    cycle_id[w] = (int)cycle.size();
                    cycle_pos[w] = (int)c.size();
                    c.push_back(w);
                    root[w] = w;
                    depth[w] = 0;
                    w = next[w];
                }
                cycle.push_back(c);
                size.push_back((int)cycle.size());
            }
            auto dfs = [&](auto self, int u)->void{
                if(~depth[u]) return;
                int v = next[u];
                self(self, v);
                root[u] = root[v];
                ++ size[cycle_id[root[u]]];
                depth[u] = depth[v] + 1;
                abr[v].push_back(u);
            };
            dfs(dfs, u);
        }
    }
    // Requires graph
    template<class Graph>
    functional_graph_processor(const Graph &g){
        int n = g.n;
        assert(n == (int)g.edge.size());
        vector<int> pv(n, -1), state(n), on_cycle(n);
        vector<vector<int>> cycle;
        auto dfs = [&](auto self, int u, int p)->void{
            state[u] = 1;
            for(auto id: g.adj[u]){
                if(g.ignore && g.ignore(id)) continue;
                auto &e = g.edge[id];
                int v = u ^ e.from ^ e.to;
                if(v == p) continue;
                if(state[v] == 1){
                    cycle.emplace_back();
                    for(auto w = u; w != v; w = pv[w]){
                        cycle.back().push_back(w);
                        on_cycle[w] = true;
                    }
                    cycle.back().push_back(v);
                    on_cycle[v] = true;
                }
                else if(state[v] == 0){
                    pv[v] = u;
                    self(self, v, u);
                }
            }
            state[u] = 2;
        };
        for(auto u = 0; u < n; ++ u){
            if(state[u] != 2){
                assert(state[u] == 0);
                dfs(dfs, u, -1);
            }
        }
        vector<int> next(n, -1);
        auto dfs2 = [&](auto self, int u, int p)->void{
            for(auto id: g.adj[u]){
                if(g.ignore && g.ignore(id)) continue;
                auto &e = g.edge[id];
                int v = u ^ e.from ^ e.to;
                if(v == p || on_cycle[v]) continue;
                next[v] = u;
                self(self, v, u);
            }
        };
        for(auto &c: cycle){
            for(auto i = 0; i < (int)c.size(); ++ i) next[c[i]] = c[(i + 1) % (int)c.size()];
            for(auto u: c) dfs2(dfs2, u, -1);
        }
        *this = functional_graph_processor(next);
    }
    int n;
    vector<vector<int>> cycle; // main cycles
    vector<int> cycle_id; // id of the cycle it belongs to, -1 if not part of one
    vector<int> cycle_pos; // position in the cycle, -1 if not part of one
    vector<int> prev; // previous vertex in the cycle, -1 if not part of one
    vector<int> size; // size of the weakly connected component of the i-th main cycle
    vector<int> root; // first reachable node in the main cycle
    vector<int> depth; // # of edges from the main cycle
    vector<vector<int>> abr; // forest of arborescences of reversed edges not on the main cycle
};

const int N = 3e5 + 5;

struct edge{
    int from, to;
    int weight;
};

int n, m, t;
edge a[N];
vi adj[N];

pii b[N];
int nxt[N];
vi adj2[N];

int dist[3][N];

void reach_t(int j, const vi& vs){
    queue <int> qu;
    Fora(s, vs){
        dist[j][s] = 0;
        qu.emplace(s);
    }
    while (not qu.empty()){
        int u = qu.front(); qu.pop();
        Fora(v, adj2[u]){
            if (dist[j][v] == -1){
                dist[j][v] = dist[j][u] + 1;
                qu.emplace(v);
            }
        }
    }
}

void count_routes(int _n, int _m, int _t, int _edge[][2], int q, int ak[]){
    n = _n; m = _m; t = _t;
    For(i, 0, m){
        auto [u, v] = pair{_edge[i][0], _edge[i][1]};
        a[i * 2] = edge{u, v, i};
        adj[u].emplace_back(i * 2);
        a[i * 2 + 1] = edge{v, u, i};
        adj[v].emplace_back(i * 2 + 1);
    }
    For(u, 0, n){
        b[u] = {-1, -1};
        Fora(i, adj[u]){
            if (b[u].fi == -1 or a[b[u].fi].weight > a[i].weight){
                b[u].se = b[u].fi;
                b[u].fi = i;
            }
            else if (b[u].se == -1 or a[b[u].se].weight > a[i].weight){
                b[u].se = i;
            }
        }
    }
    For(i, 0, 2 * m){
        if (b[a[i].to].fi != (i ^ 1) or b[a[i].to].se == -1){
            nxt[i] = b[a[i].to].fi;
        }
        else{
            nxt[i] = b[a[i].to].se;
        }
        adj2[nxt[i]].emplace_back(i);
    }
    functional_graph_processor fgp(vi(nxt, nxt + 2 * m));
    vvi spec(1);
    For(i, 0, 2 * m){
        if (a[i].to != t){
            continue;
        }
        if (fgp.cycle_id[i] == -1){
            spec[0].emplace_back(i);
        }
        else{
            spec.emplace_back(vi{i});
        }
    }
    memset(dist, -1, sizeof(dist));
    For(j, 0, isz(spec)){
        reach_t(j, spec[j]);
    }

    For(i, 0, q){
        int k = ak[i] - 1;
        int ans = 0;
        For(u, 0, n){
            int id = b[u].fi;
            For(j, 0, isz(spec)){
                if (dist[j][id] == -1){
                    continue;
                }
                if (k == dist[j][id]){
                    ans++;
                    break;
                }
                if (j != 0 and k > dist[j][id] and (k - dist[j][id]) % isz(fgp.cycle[fgp.cycle_id[spec[j][0]]]) == 0){
                    ans++;
                    break;
                }
            }
        }
        answer(ans);
    }
}

/*
==================================================+
INPUT                                             |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
OUTPUT                                            |
--------------------------------------------------|

--------------------------------------------------|
==================================================+
*/

詳細信息

Subtask #1:

score: 49
Accepted

Test #1:

score: 49
Accepted
time: 4ms
memory: 14948kb

input:

780 780 0
1 0
0 2
2 3
3 1
4 1
5 4
6 5
7 6
8 7
9 8
10 9
11 10
12 11
13 12
14 13
15 14
16 15
17 16
18 17
19 18
20 19
21 20
22 21
23 22
24 23
25 24
26 25
27 26
28 27
29 28
30 29
31 30
32 31
33 32
34 33
35 34
36 35
37 36
38 37
39 38
40 39
41 40
42 41
43 42
44 43
45 44
46 45
47 46
48 47
49 48
50 49
51 50...

output:

Correct.

Test #2:

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

input:

950 950 0
1 0
0 2
2 3
3 1
4 1
5 4
6 5
7 6
8 7
9 8
10 9
11 10
12 11
13 12
14 13
15 14
16 15
17 16
18 17
19 18
20 19
21 20
22 21
23 22
24 23
25 24
26 25
27 26
28 27
29 28
30 29
31 30
32 31
33 32
34 33
35 34
36 35
37 36
38 37
39 38
40 39
41 40
42 41
43 42
44 43
45 44
46 45
47 46
48 47
49 48
50 49
51 50...

output:

Correct.

Test #3:

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

input:

999 1099 0
1 0
0 2
2 3
3 1
4 1
5 4
6 5
7 6
8 7
9 8
10 9
11 10
12 11
13 12
14 13
15 14
16 15
17 16
18 17
19 18
20 19
21 20
22 21
23 22
24 23
25 24
26 25
27 26
28 27
29 28
30 29
31 30
32 31
33 32
34 33
35 34
36 35
37 36
38 37
39 38
40 39
41 40
42 41
43 42
44 43
45 44
46 45
47 46
48 47
49 48
50 49
51 5...

output:

Correct.

Test #4:

score: 0
Accepted
time: 0ms
memory: 15092kb

input:

45 44 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
1
100
1

output:

Correct.

Test #5:

score: 0
Accepted
time: 0ms
memory: 14740kb

input:

17 46 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
11 16
14 2
13 1
0 6
3 14
0 15
14 0
12 0
5 3
13 16
8 13
5 16
14 10
10 13
9 12
16 4
11 1
5 0
12 8
8 2
12 16
13 7
9 1
10 3
15 5
15 12
12 7
7 10
9 4
10 12
1
100
3

output:

Correct.

Test #6:

score: 0
Accepted
time: 0ms
memory: 14092kb

input:

1000 2000 7
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 0
0 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #7:

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

input:

70 170 10
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

Correct.

Test #8:

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

input:

1000 1000 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 0
8 0
9 0
10 2
11 6
12 11
13 9
14 2
15 3
16 14
17 15
18 5
19 2
20 3
21 1
22 2
23 4
24 9
25 2
26 17
27 15
28 5
29 20
30 12
31 24
32 28
33 26
34 25
35 32
36 8
37 16
38 2
39 18
40 3
41 38
42 15
43 39
44 18
45 23
46 37
47 10
48 24
49 47
50 40
51 4
52 19
53 50
54...

output:

Correct.

Test #9:

score: 0
Accepted
time: 5ms
memory: 12908kb

input:

1000 8000 0
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 0
13 4
14 0
15 10
16 5
17 6
18 14
19 2
20 6
21 10
22 18
23 18
24 0
25 10
26 22
27 11
28 5
29 16
30 14
31 2
32 0
33 0
34 9
35 24
36 34
37 34
38 37
39 15
40 22
41 1
42 32
43 10
44 18
45 35
46 21
47 45
48 32
49 16
50 30
51 44
52 31
53 ...

output:

Correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #10:

score: 20
Accepted
time: 3ms
memory: 14976kb

input:

100 100 13
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 0
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 10
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 27
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

Correct.

Test #11:

score: 0
Accepted
time: 67ms
memory: 54460kb

input:

135000 142500 2
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
65899 68039
16 0
17 18
18 19
19 20
20 21
21 22
125073 94485
22 23
23 24
24 25
25 26
26 27
27 28
77287 19161
28 29
29 30
30 31
31 32
32 33
33 34
34 17
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 ...

output:

Correct.

Test #12:

score: 0
Accepted
time: 83ms
memory: 55220kb

input:

136500 148500 5
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
16375 41566
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 0
23 3
24 10
25 22
26 14
27 25
28 23
29 20
30 9
31 2
32 0
33 23
34 32
35 7
36 6
37 9
38 7
39 31
87416 33922
40 5
41 29
42 2
43 15
44 21
45 18
46 42
47 36
48...

output:

Correct.

Test #13:

score: 0
Accepted
time: 77ms
memory: 51600kb

input:

91500 136500 20
89996 82811
0 1
30077 17428
46967 14606
1 2
2 3
3 4
4 5
20321 91440
5 6
6 7
25893 61981
7 8
84360 43614
8 9
68077 71226
9 10
23469 60159
10 11
11 12
50911 81003
12 13
4323 50214
90721 74352
13 14
75252 66390
14 15
3776 36420
15 16
16 17
58288 11702
17 18
18 19
49600 3263
19 20
20 21
...

output:

Correct.

Test #14:

score: 0
Accepted
time: 75ms
memory: 47756kb

input:

76500 136498 0
56932 48973
1 0
56331 57161
2 0
17168 73563
3736 61655
16253 38330
3 1
4 3
5 1
4642 11834
26074 3018
12112 75650
58168 23812
1684 37453
6 0
14001 44650
54304 2234
53135 45296
56151 9690
7 6
8 7
9 2
10 5
34373 20594
11 5
12 2
64635 19590
63284 21071
13 2
14 10
15 1
16 15
17 7
68264 392...

output:

Correct.

Test #15:

score: 0
Accepted
time: 76ms
memory: 57268kb

input:

150000 150000 200
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

output:

Correct.

Test #16:

score: 0
Accepted
time: 0ms
memory: 18660kb

input:

22500 22500 200
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #17:

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

input:

37500 52500 500
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #18:

score: 0
Accepted
time: 22ms
memory: 38032kb

input:

85183 85182 13
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

Correct.

Test #19:

score: 0
Accepted
time: 71ms
memory: 55216kb

input:

135000 142500 2
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 0
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 17
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

Correct.

Test #20:

score: 0
Accepted
time: 86ms
memory: 56464kb

input:

136500 148500 5
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 0
23 0
24 17
25 13
26 17
27 16
28 16
29 9
30 7
31 5
32 7
33 11
34 26
35 19
36 35
37 6
38 36
39 31
40 25
41 10
42 34
43 4
44 34
45 33
46 0
47 31
48 29
49 8
50 6
51 20
52...

output:

Correct.

Test #21:

score: 0
Accepted
time: 75ms
memory: 47792kb

input:

91500 136500 20
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #22:

score: 0
Accepted
time: 85ms
memory: 47812kb

input:

76500 136499 0
1 0
2 1
3 2
4 1
5 0
6 3
7 6
8 2
9 6
10 2
11 1
12 10
13 12
14 4
15 8
16 9
17 13
18 10
19 8
20 16
21 7
22 12
23 21
24 2
25 14
26 25
27 11
28 8
29 11
30 14
31 8
32 23
33 25
34 13
35 30
36 12
37 34
38 31
39 19
40 31
41 6
42 33
43 2
44 23
45 36
46 24
47 20
48 36
49 1
50 18
51 33
52 24
53 4...

output:

Correct.

Test #23:

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

input:

37500 52500 500
13868 25474
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
17587 629
8 9
9 10
19816 31812
11107 8848
28455 3355
10 11
11988 2929
11 12
12 13
13 14
14 15
36479 21472
2068 20945
15 16
16 17
17 18
16477 36228
18 19
19 20
24507 32786
24966 24172
20 21
21 22
22 23
23 24
24 25
24933 29140
25 26
7114 1900...

output:

Correct.

Subtask #3:

score: 31
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #24:

score: 31
Accepted
time: 0ms
memory: 14176kb

input:

100 100 13
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 0
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 10
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 27
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 ...

output:

Correct.

Test #25:

score: 0
Accepted
time: 1447ms
memory: 54708kb

input:

135000 142500 2
0 1
78631 69685
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 0
17 18
116459 101820
18 19
19 20
20 21
32482 16785
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 17
89461 85481
35 36
36 37
37 38
3105 74349
38 39
39 40
40 ...

output:

Correct.

Test #26:

score: 0
Accepted
time: 1493ms
memory: 55192kb

input:

136500 148500 5
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 0
23 8
24 6
25 18
26 13
94298 122572
27 1
28 10
29 14
30 26
42247 134674
115194 12005
31 6
32 2
33 13
34 1
35 15
36 29
37 4
38 17
39 20
40 28
41 10
113790 99619
42 4
43...

output:

Correct.

Test #27:

score: 0
Accepted
time: 670ms
memory: 51780kb

input:

91500 136500 20
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
89583 12705
15386 18856
9 10
10 11
11 12
12 13
13 14
14 15
15 16
75363 22385
16 17
17 18
18 19
67093 28419
11991 85749
19 20
15907 18111
71293 48519
20 21
21 22
22 23
20152 82707
46242 36173
23 24
18258 86900
24 25
478 62127
25 26
26 27
11670 65208...

output:

Correct.

Test #28:

score: 0
Accepted
time: 1353ms
memory: 46676kb

input:

76500 136499 0
1 0
2 0
11009 35861
3 0
4 1
5 4
6794 7931
64365 46891
6 4
7 5
65606 48720
8 5
3787 42684
39208 67987
25041 12070
9 6
27046 61933
10 0
70108 45018
29799 16017
42422 35831
11 10
12 9
13 2
14 10
15 7
11870 462
16 9
61190 47521
17 13
5646 6250
18 6
1435 74586
19 4
41896 74861
11268 466
20...

output:

Correct.

Test #29:

score: 0
Accepted
time: 1305ms
memory: 57308kb

input:

150000 150000 200
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
5...

output:

Correct.

Test #30:

score: 0
Accepted
time: 173ms
memory: 19384kb

input:

22500 22500 200
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #31:

score: 0
Accepted
time: 288ms
memory: 29212kb

input:

37500 52500 500
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #32:

score: 0
Accepted
time: 845ms
memory: 37792kb

input:

85183 85182 13
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

Correct.

Test #33:

score: 0
Accepted
time: 1430ms
memory: 55152kb

input:

135000 142500 2
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 0
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 17
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 5...

output:

Correct.

Test #34:

score: 0
Accepted
time: 1539ms
memory: 55204kb

input:

136500 148500 5
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 0
23 16
24 21
25 9
26 6
27 23
28 0
29 2
30 26
31 8
32 12
33 20
34 6
35 2
36 25
37 22
38 30
39 23
40 37
41 19
42 25
43 16
44 11
45 39
46 18
47 29
48 42
49 8
50 29
51 1
5...

output:

Correct.

Test #35:

score: 0
Accepted
time: 841ms
memory: 49636kb

input:

91500 136500 20
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 ...

output:

Correct.

Test #36:

score: 0
Accepted
time: 705ms
memory: 45988kb

input:

76500 136499 0
1 0
2 1
3 2
4 3
5 3
6 3
7 3
8 6
9 8
10 2
11 1
12 4
13 9
14 6
15 8
16 5
17 16
18 12
19 4
20 13
21 11
22 11
23 19
24 18
25 4
26 19
27 17
28 5
29 17
30 23
31 16
32 28
33 1
34 0
35 28
36 12
37 8
38 20
39 14
40 35
41 36
42 2
43 27
44 42
45 19
46 35
47 22
48 46
49 10
50 42
51 48
52 43
53 4
...

output:

Correct.

Test #37:

score: 0
Accepted
time: 159ms
memory: 26260kb

input:

37500 52499 500
0 1
1 2
20222 31256
2 3
3670 20196
3 4
4 5
23873 19374
5 6
6 7
7 8
8 9
9 10
10 11
11 12
26811 32595
12 13
13 14
16759 18923
20766 14587
14 15
15 16
16 17
17 18
20466 17598
18 19
24030 23281
19 20
20 21
21 22
22 23
23 24
24 25
4017 33535
4823 9970
25 26
26 27
27 28
24151 6384
28 29
29...

output:

Correct.