QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#702990#5088. Two Choreographiestamthegod#WA 1850ms39776kbC++233.5kb2024-11-02 16:55:072024-11-02 16:55:24

Judging History

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

  • [2024-11-02 16:55:24]
  • 评测
  • 测评结果:WA
  • 用时:1850ms
  • 内存:39776kb
  • [2024-11-02 16:55:07]
  • 提交

answer

#include<bits/stdc++.h>

#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
int n;
vector<int> adj[maxN];
int jump[maxN][20];
int depth[maxN];
pair<int, int> edge[maxN];
int mark[maxN];
void ReadInput()
{
    cin >> n;
    for(int i=1; i<=2*n-3; i++)
    {
        int u, v;
        cin >> u >> v;
        edge[i] = {u, v};
    }
}
void dfs(int u, int par)
{
    for(int v : adj[u])
    {
        if(v == par) continue;
        jump[v][0] = u;
        depth[v] = depth[u] + 1;
        for(int i=1; i<=18; i++)
            jump[v][i] = jump[jump[v][i - 1]][i - 1];
        dfs(v, u);
    }
}
int lca(int u, int v)
{
    if(depth[u] < depth[v]) swap(u, v);
    int k = depth[u] - depth[v];
    for(int i=18; i>=0; i--)
        if(k >> i & 1) u = jump[u][i];
    if(u == v) return u;
    for(int i=18; i>=0; i--)
        if(jump[u][i] != jump[v][i])
        {
            u = jump[u][i];
            v = jump[v][i];
        }
    return jump[u][0];
}
int dist(int u, int v)
{
    return depth[u] + depth[v] - 2 * depth[lca(u, v)];
}
int lab[maxN];
int findset(int u)
{
    return lab[u] < 0 ? u : lab[u] = findset(lab[u]);
}
int unite(int u, int v)
{
    int r = findset(u), s = findset(v);
    if(r == s) return false;
    if(lab[r] < lab[s]) swap(r, s);
    lab[r] += lab[s];
    lab[s] = r;
    return true;
}
void go(int x, int y)
{
    vector<int> vc1, vc2;
    int t = lca(x, y);
    while(x != t)
    {
        vc1.pb(x);
        x = jump[x][0];
    }
    while(y != t)
    {
        vc2.pb(y);
        y = jump[y][0];
    }
    vc2.pb(t);
    reverse(vc2.begin(), vc2.end());
    for(int v : vc1)
        cout << v << " ";
    for(int v : vc2)
        cout << v << " ";
    cout << '\n';
}
void print(int x, int y, int res)
{
    cout << res << '\n';
    go(edge[x].fi, edge[x].se);
    go(edge[y].fi, edge[y].se);
}
void Solve()
{
    while(true)
    {
        shuffle(edge + 1, edge + 2 * n - 2, rng);
        fill(lab, lab + n + 1, -1);
        for(int i=1; i<=n; i++)
            adj[i].clear();
        fill(mark, mark + n + 1, 0);
        for(int i=1; i<=2*n-3; i++)
        {
            if(unite(edge[i].fi, edge[i].se))
            {
                adj[edge[i].fi].pb(edge[i].se);
                adj[edge[i].se].pb(edge[i].fi);
                mark[i] = 1;
            }
        }
        dfs(1, 0);
        map<int, int> mp;
        for(int i=1; i<=2*n-3; i++)
        {
            if(mark[i]) continue;
            int len = dist(edge[i].fi, edge[i].se) + 1;
            if(len < 2) continue;
            if(mp[len])
            {
                print(mp[len], i, len);
                return;
            }
            mp[len] = i;
        }
        if(1.0 * clock() / CLOCKS_PER_SEC > 2.2)
        {
            cout << -1;
            return;
        }
    }
}
#define taskname "sol"
int32_t main()
{
    if (fopen(taskname ".inp", "r"))
    {
        freopen(taskname ".inp", "r", stdin);
        //freopen(taskname ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int T = 1;
    //cin >> T;
    for(int itest=1; itest<=T; itest++)
    {
        ReadInput();
        Solve();
    }
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 9752kb

input:

4
1 2
1 3
1 4
2 3
2 4

output:

3
1 2 3 
2 1 4 

result:

ok 

Test #2:

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

input:

5
1 2
1 3
1 4
1 5
2 3
2 5
3 4

output:

3
2 1 5 
1 2 3 

result:

ok 

Test #3:

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

input:

7
1 2
3 4
5 6
5 2
3 1
6 1
4 2
4 5
2 6
3 6
1 5

output:

3
4 2 5 
6 3 1 

result:

ok 

Test #4:

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

input:

40
1 16
1 40
2 4
2 16
2 36
3 25
3 38
4 1
4 13
5 11
5 27
6 4
7 5
7 11
8 10
8 14
8 24
9 34
10 20
12 35
13 2
14 10
14 20
15 18
15 28
15 31
16 6
16 13
17 5
17 11
17 27
18 9
19 1
19 4
19 16
20 24
21 12
21 33
21 35
22 38
23 12
23 21
25 28
25 31
25 34
25 38
26 14
26 20
27 7
27 11
28 3
28 31
29 16
29 19
30 ...

output:

3
1 19 16 
19 1 4 

result:

ok 

Test #5:

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

input:

201
1 7
1 114
1 119
2 49
2 93
4 197
5 139
6 1
6 27
7 39
7 121
8 127
9 130
9 145
11 106
11 136
11 193
12 2
12 116
13 55
13 69
13 105
13 187
13 196
14 144
14 177
15 127
15 134
15 145
15 155
15 184
15 199
16 96
16 177
17 20
21 100
22 68
22 71
22 81
22 142
23 148
23 190
24 12
24 81
24 89
25 158
25 159
2...

output:

9
1 119 48 39 7 36 106 82 114 
175 36 7 39 34 159 25 158 123 

result:

ok 

Test #6:

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

input:

8000
2 1508
2 3068
3 5268
3 5501
6 266
6 2737
6 3197
6 5863
6 6697
7 3492
9 427
9 794
9 3114
9 5509
10 2257
10 4348
11 1479
11 1957
11 2230
11 2500
11 3182
11 4399
11 5051
11 7727
12 7669
13 1403
13 5753
14 2871
14 6956
14 7959
15 6902
17 1630
17 3155
17 5950
18 7232
19 125
19 3280
19 5648
20 6879
2...

output:

12
4383 2278 7631 7358 197 1139 5671 4490 6754 511 6389 3869 
499 4371 4382 6681 2272 1528 4296 6572 5378 575 678 4995 

result:

ok 

Test #7:

score: 0
Accepted
time: 45ms
memory: 39012kb

input:

99999
1 11261
1 21544
2 9017
2 63063
2 97990
3 11995
3 42473
4 19846
5 38099
6 35872
6 80509
7 73231
8 12356
9 35384
10 45091
12 86727
13 4938
13 48917
14 62383
14 89846
15 28458
15 44277
15 51725
15 84522
16 93258
17 13934
17 42238
18 19000
19 11278
19 23672
19 61502
19 78791
20 85057
20 88080
21 2...

output:

29
99495 43298 58029 44781 13540 42647 6893 85250 66482 13182 36125 81306 84249 42156 19850 22549 64153 33158 94835 12945 98586 34826 81855 85540 51683 17555 23806 33316 43097 
6473 88086 974 54344 21925 56627 62563 43664 42237 27943 35624 97625 48093 7834 47427 53110 7942 60608 2145 29356 95991 864...

result:

ok 

Test #8:

score: 0
Accepted
time: 38ms
memory: 39016kb

input:

100000
1 68531
2 97359
4 68578
4 83098
4 98443
5 8053
5 30270
5 86617
6 7074
6 12266
6 69396
7 52675
7 78316
7 90757
7 92242
8 32677
8 41353
8 41457
8 74508
9 44234
10 4973
10 38390
10 96049
11 28007
11 68620
13 3016
14 36748
15 8147
15 25110
15 28489
15 72947
15 99347
16 70760
17 12774
17 68407
17 ...

output:

40
92882 6799 83247 32070 2134 56797 89318 74057 12022 95641 40844 66053 23511 90961 34571 1310 14384 53370 35676 19755 3200 34899 40960 89549 39255 11708 74719 95338 73374 23771 12867 60889 58354 9172 49666 20583 94119 58609 33117 30302 
38560 28457 91443 4890 74550 42027 54909 99406 76349 6193 870...

result:

ok 

Test #9:

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

input:

7
1 2
2 3
3 4
4 5
5 6
6 7
7 5
1 4
7 3
1 6
7 1

output:

3
7 6 1 
7 6 5 

result:

ok 

Test #10:

score: 0
Accepted
time: 35ms
memory: 37936kb

input:

100000
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 52
52 5...

output:

4
100000 81975 1 83412 
1 81975 100000 57953 

result:

ok 

Test #11:

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

input:

8
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 6
1 4
8 4
8 3
8 2
1 8

output:

3
1 8 2 
7 6 8 

result:

ok 

Test #12:

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

input:

9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
1 3
1 4
9 5
9 4
1 7
9 2
1 9

output:

5
1 9 5 6 7 
3 1 9 5 4 

result:

ok 

Test #13:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 8
1 4
10 6
1 6
10 4
10 3
1 9
10 1

output:

4
5 4 10 6 
1 2 3 4 

result:

ok 

Test #14:

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

input:

1000
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 52
52 53
...

output:

4
1 262 1000 607 
1000 262 1 969 

result:

ok 

Test #15:

score: 0
Accepted
time: 6ms
memory: 11132kb

input:

9999
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 52
52 53
...

output:

4
9999 592 1 5056 
9999 592 1 5329 

result:

ok 

Test #16:

score: 0
Accepted
time: 6ms
memory: 10648kb

input:

10000
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 52
52 53...

output:

4
10000 2104 1 8519 
10000 2104 1 3997 

result:

ok 

Test #17:

score: 0
Accepted
time: 37ms
memory: 37104kb

input:

94753
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 52
52 53...

output:

4
94753 84360 1 27448 
94753 84360 1 24203 

result:

ok 

Test #18:

score: 0
Accepted
time: 38ms
memory: 35512kb

input:

99999
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 52
52 53...

output:

4
99999 96099 1 28040 
99999 96099 1 31525 

result:

ok 

Test #19:

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

input:

7
1 2
2 3
3 4
4 5
5 6
6 7
1 3
1 4
1 5
1 6
1 7

output:

3
2 1 3 
3 1 4 

result:

ok 

Test #20:

score: 0
Accepted
time: 32ms
memory: 39252kb

input:

100000
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 52
52 5...

output:

3
24301 1 24302 
68720 1 68721 

result:

ok 

Test #21:

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

input:

8
1 2
2 3
3 4
4 5
5 6
6 7
7 8
1 3
1 4
1 5
1 6
1 7
1 8

output:

3
1 7 6 
7 1 8 

result:

ok 

Test #22:

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

input:

9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
1 3
1 4
1 5
1 6
1 7
1 8
1 9

output:

3
3 1 4 
1 3 2 

result:

ok 

Test #23:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10

output:

3
1 9 8 
6 1 7 

result:

ok 

Test #24:

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

input:

1000
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 52
52 53
...

output:

3
717 1 718 
718 1 719 

result:

ok 

Test #25:

score: 0
Accepted
time: 6ms
memory: 12560kb

input:

9999
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 52
52 53
...

output:

3
1 9094 9095 
1 9813 9814 

result:

ok 

Test #26:

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

input:

10000
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 52
52 53...

output:

3
862 1 863 
1 4838 4839 

result:

ok 

Test #27:

score: 0
Accepted
time: 35ms
memory: 34608kb

input:

97065
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 52
52 53...

output:

3
1 35354 35353 
1 92923 92922 

result:

ok 

Test #28:

score: 0
Accepted
time: 38ms
memory: 39200kb

input:

99999
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 52
52 53...

output:

3
1 32449 32450 
1 13903 13904 

result:

ok 

Test #29:

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

input:

7
1 2
2 3
3 4
4 5
5 6
6 7
7 5
7 4
7 3
7 2
7 1

output:

3
7 1 2 
7 6 5 

result:

ok 

Test #30:

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

input:

100000
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 52
52 5...

output:

3
100000 9331 9330 
100000 28539 28540 

result:

ok 

Test #31:

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

input:

8
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 6
8 5
8 4
8 3
8 2
8 1

output:

3
4 8 5 
5 8 6 

result:

ok 

Test #32:

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

input:

9
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 7
9 6
9 5
9 4
9 3
9 2
9 1

output:

3
9 5 6 
9 2 1 

result:

ok 

Test #33:

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

input:

10
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 8
10 7
10 6
10 5
10 4
10 3
10 2
10 1

output:

4
10 2 3 4 
10 6 7 8 

result:

ok 

Test #34:

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

input:

1000
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 52
52 53
...

output:

4
1000 201 200 199 
869 868 1000 870 

result:

ok 

Test #35:

score: 0
Accepted
time: 6ms
memory: 12820kb

input:

9999
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 52
52 53
...

output:

3
9999 3892 3891 
490 9999 491 

result:

ok 

Test #36:

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

input:

10000
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 52
52 53...

output:

3
10000 5890 5889 
10000 8215 8214 

result:

ok 

Test #37:

score: 0
Accepted
time: 33ms
memory: 36692kb

input:

92892
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 52
52 53...

output:

3
92892 9978 9979 
27858 92892 27859 

result:

ok 

Test #38:

score: 0
Accepted
time: 39ms
memory: 39072kb

input:

99999
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 52
52 53...

output:

3
99999 65170 65169 
99999 26779 26780 

result:

ok 

Test #39:

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

input:

8
5 6
7 3
2 3
7 8
1 5
2 8
8 5
4 5
8 1
7 6
3 4
2 6
2 1

output:

4
7 3 2 8 
5 1 2 6 

result:

ok 

Test #40:

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

input:

10
6 7
1 7
2 5
2 4
5 4
10 4
3 2
6 5
10 5
2 8
4 1
1 2
8 9
7 8
3 10
9 10
4 3

output:

3
10 3 4 
3 4 2 

result:

ok 

Test #41:

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

input:

1000
272 271
393 394
369 404
981 980
169 185
362 361
387 386
482 481
383 382
370 788
266 106
938 223
876 877
107 106
109 110
481 480
633 14
886 885
588 589
673 567
568 693
531 932
562 561
871 872
89 959
951 950
119 556
484 891
981 271
75 74
443 444
865 730
374 15
580 233
716 165
882 829
622 623
606 ...

output:

12
570 610 471 358 357 555 369 368 294 293 292 544 
288 289 290 958 957 683 684 200 199 841 52 287 

result:

ok 

Test #42:

score: 0
Accepted
time: 6ms
memory: 14700kb

input:

9999
1503 1502
1862 3917
4579 4578
9929 8919
4989 4990
4479 7716
5512 5511
4389 4390
4430 910
5616 3889
5708 5879
8848 8849
5400 5076
7827 3718
1169 1168
1574 213
3196 4013
2414 2415
2857 2858
9177 9178
7189 7190
3550 3549
7446 5351
7766 8059
2132 2646
8813 7870
2521 2522
5158 5157
4623 4624
4957 49...

output:

80
931 8371 8372 8758 6060 7589 2477 3500 3499 3498 8678 5357 5356 5355 921 920 1483 6699 6700 9572 9571 8403 8404 8405 8406 6075 3369 3106 1634 1633 4831 4832 1711 1710 1709 9244 8045 8046 4636 6242 6241 3655 8974 8975 4083 6358 6357 6356 9194 695 5660 5661 5662 5663 5664 5665 7153 7152 1886 486 93...

result:

ok 

Test #43:

score: 0
Accepted
time: 6ms
memory: 11308kb

input:

10000
5462 4989
4542 4541
7300 8478
4730 3574
7930 7051
750 7627
117 3045
4274 4275
3840 3841
5706 3638
7108 7107
28 29
2564 2563
2784 2393
1193 1192
2040 1286
3688 3687
8048 2319
2404 2405
8641 8640
6992 8729
5085 5086
5130 5131
6813 9806
6592 6769
2806 2805
7482 6021
7371 3994
4939 3217
1905 6540
...

output:

104
1595 6168 6167 1635 979 2454 2453 3077 7989 4976 4977 9155 7449 8640 8639 4265 1802 1801 9631 9215 6079 6078 6077 3659 5789 5790 7504 442 5375 5374 5373 4404 6729 3421 3422 4050 6936 8796 8575 8574 8573 8634 8635 934 9763 5251 5252 7058 7057 7841 7842 3281 3280 2771 2770 9607 7740 7857 9668 2928...

result:

ok 

Test #44:

score: 0
Accepted
time: 41ms
memory: 37500kb

input:

99999
49253 51314
3093 3092
88617 72981
43336 77222
65739 55450
5166 90677
57235 57234
51512 51511
73274 86124
86611 77777
21808 21809
2794 2795
64109 69571
80102 80101
56177 27689
55899 58255
16908 16909
53732 53733
9213 9214
33157 33158
10706 10707
76016 11308
51459 74662
58149 58150
80976 56845
2...

output:

89
39153 9848 28346 28347 21250 21249 23417 2774 90642 73827 68560 45879 54369 83862 83861 60270 60271 60272 49624 30384 30383 30382 89482 89483 87820 89437 89438 69314 54679 83190 83191 21305 15680 13228 13229 56249 1548 1547 66064 84450 84449 93051 93052 93053 3754 67497 67496 67495 21005 21004 12...

result:

ok 

Test #45:

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

input:

96827
15894 15895
33528 48199
50450 50451
63703 63702
49937 31980
93823 45726
96052 96051
54334 16426
9193 11656
49315 10079
10614 33488
84027 84028
3612 5321
64903 64904
56901 32611
33578 68521
47938 47939
32618 53239
89613 89612
82729 82728
34512 34511
54064 38673
56419 56420
23775 75336
85989 172...

output:

69
80094 47211 47212 59247 59246 85543 85542 90386 90385 92890 92889 80055 80056 80057 40866 40865 35928 37007 37008 80675 80674 49091 70787 30965 30964 18292 3224 35776 65840 65841 35676 28942 28941 74536 37192 15894 47390 47391 27977 88147 4340 27239 27238 69812 69813 291 290 60950 60949 82389 289...

result:

ok 

Test #46:

score: 0
Accepted
time: 43ms
memory: 37380kb

input:

100000
72105 72104
4352 4351
59159 59160
78993 64103
39235 39234
4458 36615
23543 53027
54635 54634
80821 80822
8720 72158
49535 78364
64357 3035
93490 6597
52195 13285
70186 70187
14748 98067
15516 71738
77617 77616
68836 68835
61569 61570
28477 28289
50823 50822
71759 49859
59464 59463
83701 83702...

output:

7
85098 90271 927 27986 27985 45230 90874 
91333 82314 82315 55419 48001 1637 98200 

result:

ok 

Test #47:

score: 0
Accepted
time: 47ms
memory: 37704kb

input:

100000
53877 17887
7877 7878
35510 37710
15520 83926
7572 7573
11839 11840
75139 75140
63678 63679
66199 66198
3262 3263
78203 78204
87574 87575
53474 67658
86593 86594
28943 17005
71369 264
3802 41402
30583 30584
38511 38510
36776 90902
57208 57209
15408 48313
73488 46167
88419 93118
57411 57412
42...

output:

229
61368 61369 61370 61371 8938 47347 17677 51245 51246 51247 41403 92351 92352 5877 69523 66334 76559 76560 51514 21371 92553 13027 13026 11934 93023 9893 9892 74708 11680 11679 36086 36085 36084 36083 49640 10468 19583 19582 12432 37194 37195 72216 72217 13875 70685 61865 61866 22208 22207 22206 ...

result:

ok 

Test #48:

score: 0
Accepted
time: 38ms
memory: 39468kb

input:

100000
78895 34726
20392 44705
57147 22069
31133 31132
78946 78947
53758 53757
68970 68971
75904 87094
12439 12438
92849 92848
80817 80818
76732 53635
79930 79931
78362 78363
87661 87662
47807 47808
73696 27386
30646 30645
17648 81813
47120 47119
84905 84906
87235 8058
8238 88843
86537 12191
68784 6...

output:

88
8079 78660 88359 55101 55100 55099 72278 29507 29506 99901 99900 99899 99898 37737 37738 96717 96718 53274 53273 50130 50129 66451 79362 87486 87485 15415 15414 10718 82642 16129 91210 21884 78679 78680 25919 72546 32577 32576 32575 61648 67102 67101 52236 52237 11086 23800 23799 41257 41256 9812...

result:

ok 

Test #49:

score: 0
Accepted
time: 44ms
memory: 34588kb

input:

94055
34740 73546
30256 30255
20298 20299
62592 62591
49467 49468
65041 2277
38788 38787
58735 65469
2375 2376
77665 77666
36242 80298
75550 16701
13820 64701
83448 83449
79313 83990
2213 2212
22172 22171
72441 92184
10391 30730
39194 38883
25064 90160
69140 85068
50433 31078
58353 4381
38997 38998
...

output:

140
32134 30336 9512 9511 9510 56732 29684 29683 29682 29681 70292 46154 29188 29187 29186 24270 24271 24272 24273 51106 51107 82800 82801 12994 12995 12996 74874 74875 74876 74877 47547 47548 47549 27996 27995 27994 27993 71387 71388 62130 62131 65786 71842 71841 9053 38666 38665 73531 73530 73529 ...

result:

ok 

Test #50:

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

input:

7
6 2
4 3
3 7
7 6
1 2
7 2
1 5
6 5
4 5
5 7
2 3

output:

4
7 3 2 6 
4 3 7 5 

result:

ok 

Test #51:

score: 0
Accepted
time: 45ms
memory: 39316kb

input:

99084
7128 52592
26282 84361
19470 70586
2431 2430
33596 72767
70001 70000
65483 65484
76493 76492
62792 39465
4476 31233
72512 72511
94244 69778
84662 84663
32214 32213
4717 4718
73918 26226
71389 71390
45765 45764
87589 87590
6207 6206
47094 70119
30908 29826
34602 40286
44413 44412
21890 21889
24...

output:

38
49053 88106 88105 88104 88103 81624 81623 54235 56071 54285 26677 70897 16977 77790 10378 10379 17471 39419 39420 39421 39422 47526 11928 11927 73276 73277 39164 2602 97161 19550 8651 8652 96388 41321 49755 49756 64051 49054 
67995 80816 88103 81624 81623 54235 56071 54285 26677 70897 16977 77790...

result:

ok 

Test #52:

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

input:

8
6 5
3 4
2 3
3 7
2 4
6 7
4 8
5 2
2 1
1 6
7 8
5 4
8 1

output:

4
1 8 7 6 
4 2 1 8 

result:

ok 

Test #53:

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

input:

9
6 7
7 3
9 8
4 3
2 1
6 2
6 8
5 6
7 8
1 4
9 4
4 5
9 6
1 9
2 3

output:

3
9 6 8 
6 8 7 

result:

ok 

Test #54:

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

input:

9
5 4
1 5
3 2
1 2
2 9
6 7
1 8
3 4
7 5
5 6
5 9
6 3
9 1
7 8
8 9

output:

5
5 6 3 2 9 
1 5 6 7 8 

result:

ok 

Test #55:

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

input:

10
1 8
10 9
4 9
6 4
2 1
2 3
7 2
4 5
10 3
5 8
2 9
6 5
8 9
4 8
6 7
7 8
3 4

output:

5
7 2 3 4 8 
2 3 4 8 9 

result:

ok 

Test #56:

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

input:

9
5 6
8 7
1 2
5 2
8 6
6 9
9 8
2 9
4 7
4 1
4 5
6 1
2 3
3 4
7 6

output:

4
4 1 6 7 
5 4 1 6 

result:

ok 

Test #57:

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

input:

10
1 2
3 2
6 8
5 4
5 6
8 7
4 1
6 7
4 3
2 5
3 10
8 9
6 2
10 1
9 3
8 4
9 10

output:

3
9 10 3 
5 2 6 

result:

ok 

Test #58:

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

input:

9
3 6
2 1
5 6
9 7
4 2
4 3
1 3
8 9
1 5
6 7
4 6
1 9
7 8
4 5
2 3

output:

3
4 3 6 
8 7 9 

result:

ok 

Test #59:

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

input:

4
1 2
4 1
4 3
3 1
4 2

output:

3
4 1 2 
3 4 1 

result:

ok 

Test #60:

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

input:

10
8 10
10 9
7 8
8 3
6 3
1 3
9 6
1 8
5 10
3 4
10 4
3 9
2 1
1 9
6 5
6 10
9 5

output:

3
3 1 9 
10 6 9 

result:

ok 

Test #61:

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

input:

1000
937 387
833 217
405 422
502 356
529 374
497 662
803 845
726 979
999 43
463 620
749 828
661 573
191 708
513 963
737 819
439 571
787 166
873 842
993 566
590 908
34 184
699 314
756 255
996 242
653 402
451 656
90 762
562 382
945 397
600 816
789 890
378 965
613 827
319 645
156 684
477 570
131 419
43...

output:

16
641 630 484 88 980 672 180 797 214 562 595 470 52 738 469 585 
851 371 910 272 203 594 169 299 384 646 117 517 360 518 502 31 

result:

ok 

Test #62:

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

input:

9999
2524 8191
1533 7530
356 1008
8210 3560
2071 540
2876 4324
9158 3771
2872 5625
4701 4769
4728 2104
2264 9841
4009 2392
9900 4852
9836 1027
3996 1557
97 1319
5587 7722
7488 4073
2940 9762
246 6394
380 6935
7929 3557
8049 8841
2105 7255
2710 6626
7926 6255
8392 6949
6174 2040
9959 8955
8701 3730
5...

output:

50
5171 1406 2979 2968 3184 8162 9439 992 4320 2314 5502 7183 5173 103 9513 859 588 5454 6989 6467 6541 5649 5506 644 1929 1217 3304 2985 403 6374 2199 6020 2354 2820 9083 9314 6947 4731 8009 1524 4911 4627 8777 4845 924 4512 4918 7309 1385 2137 
9112 5490 7611 2831 5761 4686 7561 1298 8162 9439 992...

result:

ok 

Test #63:

score: 0
Accepted
time: 6ms
memory: 12516kb

input:

10000
8697 615
9680 5350
5924 4698
4478 7356
3510 7535
6046 3305
885 4890
8224 2297
2267 8411
7331 7035
1747 7766
3540 1409
4143 212
9541 5746
1062 539
2060 9566
5293 350
6143 2220
1446 2866
4603 4151
9625 5078
3432 4169
1528 1525
9522 2738
3154 3100
8560 9024
1200 4420
3138 9200
2346 182
1694 6303
...

output:

87
613 8411 4628 3027 1129 1448 432 8652 3236 1166 6190 5740 4336 507 3866 1934 7369 2583 6845 8618 129 3345 1727 2957 5152 6170 2163 6469 4518 1998 5992 4549 8470 3841 5264 9794 4224 6304 1588 4586 2791 9323 4293 4357 3120 8142 891 3601 8041 3909 4885 9182 6010 9513 1292 5122 675 9521 446 3167 8055...

result:

ok 

Test #64:

score: 0
Accepted
time: 35ms
memory: 39776kb

input:

99999
84520 53880
95569 33800
30674 78149
34453 98159
29766 87018
38710 45543
78103 64279
95388 6083
90709 6245
28076 59536
89121 25989
17455 86681
24869 49677
88947 54071
59069 14675
2211 80543
84618 24731
71749 96646
3072 81888
41124 19659
78748 83891
86353 92485
51719 3101
86489 39980
2846 67916
...

output:

84
52789 47214 93061 96608 61735 73710 41826 47215 84890 14238 84908 80795 77215 26548 85015 20390 40981 16722 22894 93868 12385 15765 92647 86923 84641 56804 97374 64203 80920 58146 43196 71086 14121 46372 34123 15110 18716 20179 52116 13032 57357 61670 53270 79611 74568 89007 60172 70910 27747 979...

result:

ok 

Test #65:

score: 0
Accepted
time: 35ms
memory: 37032kb

input:

91648
4472 25803
85060 29770
38233 78885
69505 11992
74584 56733
44447 19721
38611 47816
64374 1051
85078 88959
3376 77926
30914 66149
47776 2665
24048 19740
63674 58321
31035 27289
28597 78620
26732 63968
3921 28544
88344 48945
17800 78918
39469 31300
58279 76356
88378 67190
87900 74995
96 31664
86...

output:

193
24700 2391 68751 10726 49587 54428 43507 74368 38985 57124 28934 41769 14310 4254 54338 81724 24471 944 15826 64624 65910 54351 22314 26240 67990 63158 7606 88276 80184 73005 33524 66796 44417 4741 5885 82767 17076 73782 52594 73582 67877 46003 89473 32610 52149 18580 7880 11837 56882 31440 1476...

result:

ok 

Test #66:

score: 0
Accepted
time: 46ms
memory: 35136kb

input:

100000
13352 1027
26975 28733
58784 97055
76806 68544
9735 23022
13365 25281
80851 10373
95287 91860
59771 31042
51912 68412
26741 29961
34375 25709
13755 46111
50736 39736
95695 18184
57397 62912
97590 59408
6754 50322
16563 80551
76371 58366
31788 49867
41825 95414
16211 24996
32999 62870
4946 820...

output:

123
26636 44384 22566 14100 82926 42652 70337 64457 29848 62841 7291 28625 94433 33578 64455 86195 19897 13701 95906 39681 12349 55439 3592 79121 43719 53520 91325 22083 41429 81022 85665 19491 38386 43584 85404 40335 66156 80418 84457 68435 3355 53798 1381 48492 5064 64417 23831 16101 30006 787 575...

result:

ok 

Test #67:

score: 0
Accepted
time: 39ms
memory: 35112kb

input:

100000
20959 25336
91898 62660
72720 51175
61002 85224
24094 15898
17841 75902
96298 91723
60352 50707
73566 69660
14089 5220
50982 29437
79898 86395
1734 56103
52555 46603
63369 73948
72151 60200
25210 3152
38452 28051
85173 32730
57691 99457
69691 30053
2072 97708
97968 56344
65532 44367
12342 346...

output:

69
21649 68389 37964 70313 75070 23912 83635 978 72929 16083 3406 20409 15718 93292 3805 79037 69403 28523 65334 23536 55166 93327 46396 87503 47874 24600 69414 92514 51599 1186 86251 8362 91078 92356 11839 86881 9631 45146 86775 86567 25266 73565 67618 34924 49592 82287 81118 46203 27801 43393 9790...

result:

ok 

Test #68:

score: 0
Accepted
time: 43ms
memory: 37768kb

input:

100000
16435 98228
89180 57831
43189 90862
16293 29922
91964 47722
34278 901
54950 37026
95302 76757
42452 74646
38280 38053
65541 27258
36041 61691
27600 40344
23817 62272
71323 52794
81547 61348
39381 11415
52865 23221
79787 93823
91146 34985
66479 79975
16439 79659
36874 49350
50891 86175
33479 5...

output:

43
3847 98537 77230 54162 87937 90958 97265 59500 73731 49617 76054 42269 38334 58079 6685 58248 4016 55345 43275 45528 54243 92263 78670 46890 16548 15229 38918 83417 22885 36370 47155 74429 59827 12597 13735 81339 83380 72539 67582 24693 93407 12392 59721 
41076 52289 81098 21593 40493 6594 84287 ...

result:

ok 

Test #69:

score: 0
Accepted
time: 44ms
memory: 39088kb

input:

95728
48566 69797
54999 85490
75942 40279
51954 81016
58241 2418
39067 29211
81791 12312
77375 65571
56275 38417
19545 83406
22125 73565
35590 62148
23344 55309
39501 86411
68603 19541
75927 74829
9467 14763
65439 91977
45467 52791
94490 35940
32928 3568
76229 95312
78704 76042
23090 10023
59356 602...

output:

166
40636 69912 75560 79339 93088 21138 91399 31597 12753 673 28327 14099 82506 27537 69981 14923 73114 4139 1810 93730 20655 14369 17199 67248 28158 33135 37509 78617 16498 31424 41487 85089 87279 65578 42638 5156 53946 77631 58253 24738 41678 87932 29674 28645 51067 71736 24176 59600 9933 63213 48...

result:

ok 

Test #70:

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

input:

5
2 4
2 3
5 3
5 1
1 3
4 5
1 2

output:

4
2 3 5 4 
1 5 3 2 

result:

ok 

Test #71:

score: 0
Accepted
time: 35ms
memory: 36720kb

input:

93309
71437 20546
7225 87604
42872 46689
48394 70601
79628 80229
46286 21730
85596 24788
78402 13849
4309 88242
46678 82455
59146 64364
43993 73409
35381 77031
24159 45740
49493 15690
53789 31467
78790 88954
13595 76316
85033 35716
5254 44215
33086 43366
81849 23644
22197 53918
78118 73130
44242 230...

output:

140
24586 80125 30602 73899 84647 41531 91877 24766 67690 44743 29689 89613 10512 92370 90715 825 65780 21972 73133 75656 43545 38463 14704 21995 56563 76045 36292 88325 85027 69918 82354 7935 40690 3190 48427 76188 59441 91220 18425 37788 16377 9671 20124 61915 78947 38982 69943 62534 6828 123 1731...

result:

ok 

Test #72:

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

input:

6
5 3
1 3
5 2
5 1
3 6
6 4
1 2
5 6
3 2

output:

3
3 1 2 
5 1 3 

result:

ok 

Test #73:

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

input:

7
6 3
5 4
7 1
1 6
3 1
7 3
2 7
7 4
3 5
2 5
7 5

output:

3
5 7 4 
7 5 3 

result:

ok 

Test #74:

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

input:

8
5 1
7 6
7 3
7 5
1 8
3 2
6 5
1 4
6 1
7 8
6 3
7 4
8 6

output:

3
7 6 5 
8 7 6 

result:

ok 

Test #75:

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

input:

9
1 3
4 8
2 4
8 6
5 4
8 5
9 2
9 4
8 9
1 6
2 3
5 2
4 7
7 1
9 5

output:

3
2 5 4 
8 4 5 

result:

ok 

Test #76:

score: -100
Wrong Answer
time: 1850ms
memory: 7832kb

input:

10
6 5
8 3
8 9
9 10
3 4
10 6
7 8
6 9
2 3
4 7
6 8
4 10
6 3
6 4
5 10
5 4
9 5

output:

-1

result:

wrong answer Integer -1 violates the range [3, 10]