QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#532098#5088. Two ChoreographiesTiga_Pilot_2AC ✓68ms34960kbC++204.3kb2024-08-25 00:09:442024-08-25 00:09:44

Judging History

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

  • [2024-08-25 00:09:44]
  • 评测
  • 测评结果:AC
  • 用时:68ms
  • 内存:34960kb
  • [2024-08-25 00:09:44]
  • 提交

answer

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i > (b); --i)
#define ar array
#define sz(x) (int) (x).size()
#define pii pair<int,int>
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
typedef vector<int> vi;
#define all(x) (x).begin(), (x).end()

template<typename T>
void min_self(T& A, T B) {
    A = min(A,B);
}
template<typename T>
void max_self(T& A, T B) {
    A = max(A,B);
}

const int mxn=1e5;
int n;

struct UF {
	vi e;
	UF(int n) : e(n, -1) {}
	bool sameSet(int a, int b) { return find(a) == find(b); }
	int size(int x) { return -e[find(x)]; }
	int find(int x) { return e[x] < 0 ? x : e[x] = find(e[x]); }
	bool join(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return false;
		if (e[a] > e[b]) swap(a, b);
		e[a] += e[b]; e[b] = a;
		return true;
	}
};

vector<vi> treeJump(vi& P){
	int on = 1, d = 1;
	while(on < sz(P)) on *= 2, d++;
	vector<vi> jmp(d, P);
	rep(i,1,d) rep(j,0,sz(P))
		jmp[i][j] = jmp[i-1][jmp[i-1][j]];
	return jmp;
}

int jmp(vector<vi>& tbl, int nod, int steps){
	rep(i,0,sz(tbl))
		if(steps&(1<<i)) nod = tbl[i][nod];
	return nod;
}

int lca(vector<vi>& tbl, vi& depth, int a, int b) {
	if (depth[a] < depth[b]) swap(a, b);
	a = jmp(tbl, a, depth[a] - depth[b]);
	if (a == b) return a;
	for (int i = sz(tbl); i--;) {
		int c = tbl[i][a], d = tbl[i][b];
		if (c != d) a = c, b = d;
	}
	return tbl[0][a];
}


void solve() {
    cin >>n;
    UF uf(n);
    vector<pii> exc;
    vector adj(n, vi());
    rep(i,0,n*2-3) {
        int u,v; cin >>u >>v; u--,v--;
        if(uf.join(u,v)) {
            adj[u].push_back(v);
            adj[v].push_back(u);
        } else {
            exc.push_back({u,v});
        }
    }
    vi par,dp;
    par.resize(n);
    iota(par.begin(),par.end(),0);
    dp.resize(n,0);
    function<void(int,int)> dfs;
    dfs = [&](int u, int pr) -> void {
        for(int v: adj[u]) {
            if(v==pr) continue;
            par[v] = u;
            dp[v] = dp[u]+1;
            dfs(v,u);
        }
    };
    rep(i,0,n) {
        if(par[i]==i) {
            dfs(i,-1);
        }
    }
    auto tbl = treeJump(par);
    map<int,pii> mp;
    auto crtAns = [&](vi& ans, int u, int v) -> void {
        vi tmp1, tmp2;
        int lc = lca(tbl, dp, u,v);
        int x = u;
        while(x!=lc) {
            tmp1.push_back(x);
            x = par[x];
        }
        x = v;
        while(x!=lc) {
            tmp2.push_back(x);
            x = par[x];
        }
        rep(i,0,sz(tmp1)) {
            ans.push_back(tmp1[i]);
        }
        ans.push_back(lc);
        per(i,sz(tmp2)-1,-1) {
            ans.push_back(tmp2[i]);
        }
    };
    for(auto [u,v]: exc) {
        int ds = dp[u]+dp[v]-dp[lca(tbl, dp,u,v)]*2;
        if(mp.count(ds)) {
            cout <<ds+1 <<"\n";
            vi ans1,ans2;
            crtAns(ans1, u,v);
            auto [u2,v2] = mp[ds];
            crtAns(ans2, u2, v2);
            rep(i,0,sz(ans1)) {
                cout <<ans1[i]+1 <<" \n"[i==sz(ans1)-1];
            }
            rep(i,0,sz(ans2)) {
                cout <<ans2[i]+1 <<" \n"[i==sz(ans2)-1];
            }
            return;
        }
        mp[ds] = {u,v};
    }
    int ds = n-2;
    auto [un,vn] = mp[n-1];
    auto [u2,v2] = mp[2];
    if(dp[un]>dp[vn]) swap(un,vn);
    if(dp[u2]>dp[v2]) swap(u2,v2);
    auto toP = [&](vi& ans, int u, int p) -> void {
        while(u!=p) {
            ans.push_back(u);
            u = par[u];
        }
    };
    if(mp.count(ds)) {
        cout <<ds+1 <<"\n";
        vi ans1,ans2;
        toP(ans1, vn, v2);
        ans1.push_back(v2);
        toP(ans1, u2, un);
        ans1.push_back(un);
        auto [ux,vx] = mp[ds];
        crtAns(ans2, ux, vx);
        rep(i,0,sz(ans1)) {
            cout <<ans1[i]+1 <<" \n"[i==sz(ans1)-1];
        }
        rep(i,0,sz(ans2)) {
            cout <<ans2[i]+1 <<" \n"[i==sz(ans2)-1];
        }        
        return;
    }
    assert(false);
    cout <<"-1\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
1 3
1 4
2 3
2 4

output:

3
2 1 4
2 1 3

result:

ok 

Test #2:

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

input:

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

output:

3
2 1 5
2 1 3

result:

ok 

Test #3:

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

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:

4
4 3 1 2
6 5 2 1

result:

ok 

Test #4:

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

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
13 4 2
7 5 11

result:

ok 

Test #5:

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

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:

5
48 39 7 1 119
48 39 7 1 114

result:

ok 

Test #6:

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

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:

7
711 320 5791 479 7707 42 7178
602 242 284 2325 314 4274 399

result:

ok 

Test #7:

score: 0
Accepted
time: 40ms
memory: 17760kb

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:

23
15095 30660 4903 76986 11743 46207 3594 22313 10591 10246 8898 2764 43628 10655 5428 5754 8745 82174 5288 6606 1256 6036 51472
14003 7702 64252 11902 10033 22483 446 34344 8669 5309 6827 96498 7078 74590 10232 4591 57501 6120 67209 5392 7119 4069 58311

result:

ok 

Test #8:

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

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:

6
10589 7666 6859 35358 9196 10402
8544 6160 1461 29348 4654 37226

result:

ok 

Test #9:

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

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:

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

result:

ok 

Test #10:

score: 0
Accepted
time: 64ms
memory: 34896kb

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:

99999
100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952...

result:

ok 

Test #11:

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

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:

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

result:

ok 

Test #12:

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

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:

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

result:

ok 

Test #13:

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

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:

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

result:

ok 

Test #14:

score: 0
Accepted
time: 1ms
memory: 3920kb

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:

999
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927...

result:

ok 

Test #15:

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

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:

9998
9999 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941 9940 ...

result:

ok 

Test #16:

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

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:

9999
10000 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941...

result:

ok 

Test #17:

score: 0
Accepted
time: 59ms
memory: 33256kb

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:

94752
94753 94752 94751 94750 94749 94748 94747 94746 94745 94744 94743 94742 94741 94740 94739 94738 94737 94736 94735 94734 94733 94732 94731 94730 94729 94728 94727 94726 94725 94724 94723 94722 94721 94720 94719 94718 94717 94716 94715 94714 94713 94712 94711 94710 94709 94708 94707 94706 94705 ...

result:

ok 

Test #18:

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

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:

99998
99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 99951 ...

result:

ok 

Test #19:

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

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:

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

result:

ok 

Test #20:

score: 0
Accepted
time: 59ms
memory: 34960kb

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:

99999
100000 99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952...

result:

ok 

Test #21:

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

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:

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

result:

ok 

Test #22:

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

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:

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

result:

ok 

Test #23:

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

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:

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

result:

ok 

Test #24:

score: 0
Accepted
time: 1ms
memory: 3900kb

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:

999
1000 999 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927...

result:

ok 

Test #25:

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

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:

9998
9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941 ...

result:

ok 

Test #26:

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

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:

9999
10000 9999 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942...

result:

ok 

Test #27:

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

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:

97064
97065 97064 97063 97062 97061 97060 97059 97058 97057 97056 97055 97054 97053 97052 97051 97050 97049 97048 97047 97046 97045 97044 97043 97042 97041 97040 97039 97038 97037 97036 97035 97034 97033 97032 97031 97030 97029 97028 97027 97026 97025 97024 97023 97022 97021 97020 97019 97018 97017 ...

result:

ok 

Test #28:

score: 0
Accepted
time: 63ms
memory: 34880kb

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:

99998
99999 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 99951 ...

result:

ok 

Test #29:

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

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:

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

result:

ok 

Test #30:

score: 0
Accepted
time: 61ms
memory: 34912kb

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:

99999
100000 99998 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 99951...

result:

ok 

Test #31:

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

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:

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

result:

ok 

Test #32:

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

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:

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

result:

ok 

Test #33:

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

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:

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

result:

ok 

Test #34:

score: 0
Accepted
time: 1ms
memory: 3864kb

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:

999
1000 998 997 996 995 994 993 992 991 990 989 988 987 986 985 984 983 982 981 980 979 978 977 976 975 974 973 972 971 970 969 968 967 966 965 964 963 962 961 960 959 958 957 956 955 954 953 952 951 950 949 948 947 946 945 944 943 942 941 940 939 938 937 936 935 934 933 932 931 930 929 928 927 926...

result:

ok 

Test #35:

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

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:

9998
9999 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941 9940 ...

result:

ok 

Test #36:

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

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:

9999
10000 9998 9997 9996 9995 9994 9993 9992 9991 9990 9989 9988 9987 9986 9985 9984 9983 9982 9981 9980 9979 9978 9977 9976 9975 9974 9973 9972 9971 9970 9969 9968 9967 9966 9965 9964 9963 9962 9961 9960 9959 9958 9957 9956 9955 9954 9953 9952 9951 9950 9949 9948 9947 9946 9945 9944 9943 9942 9941...

result:

ok 

Test #37:

score: 0
Accepted
time: 65ms
memory: 32628kb

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:

92891
92892 92890 92889 92888 92887 92886 92885 92884 92883 92882 92881 92880 92879 92878 92877 92876 92875 92874 92873 92872 92871 92870 92869 92868 92867 92866 92865 92864 92863 92862 92861 92860 92859 92858 92857 92856 92855 92854 92853 92852 92851 92850 92849 92848 92847 92846 92845 92844 92843 ...

result:

ok 

Test #38:

score: 0
Accepted
time: 68ms
memory: 34924kb

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:

99998
99999 99997 99996 99995 99994 99993 99992 99991 99990 99989 99988 99987 99986 99985 99984 99983 99982 99981 99980 99979 99978 99977 99976 99975 99974 99973 99972 99971 99970 99969 99968 99967 99966 99965 99964 99963 99962 99961 99960 99959 99958 99957 99956 99955 99954 99953 99952 99951 99950 ...

result:

ok 

Test #39:

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

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 8 5 6
2 3 7 8

result:

ok 

Test #40:

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

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:

5
7 6 5 2 8
1 7 6 5 2

result:

ok 

Test #41:

score: 0
Accepted
time: 1ms
memory: 3696kb

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:

46
819 514 932 531 470 469 328 48 49 50 722 501 500 499 959 89 536 726 725 635 636 637 638 339 340 52 287 288 233 580 324 547 548 357 555 554 553 968 969 881 841 199 919 920 921 818
793 792 892 891 484 485 259 883 444 445 844 845 846 513 825 824 657 928 929 315 321 192 516 515 514 932 531 470 469 32...

result:

ok 

Test #42:

score: 0
Accepted
time: 4ms
memory: 4700kb

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:

53
1495 1494 7189 1879 7261 7262 7263 9335 3368 5816 7388 7389 3487 3185 4817 4816 7284 7467 7312 1262 8304 7302 7303 1397 1398 8113 8114 9509 9975 9976 447 446 25 9311 9312 7249 5698 9759 9760 5900 5899 3353 3155 1536 3229 576 575 6099 6943 9748 9749 2809 890
466 1581 1580 1579 5364 6186 6185 7770 ...

result:

ok 

Test #43:

score: 0
Accepted
time: 4ms
memory: 4544kb

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:

88
4530 3231 3974 3973 3972 3971 2919 2920 6400 9295 9294 9740 9741 5640 3612 1721 1720 1801 9631 2540 9240 1461 4881 4882 9966 573 9047 6157 6158 7725 7726 5759 2820 2819 4800 3448 6032 7346 9497 4566 4567 2002 2001 2000 1999 1998 1010 5116 3573 3574 4730 4729 4728 789 788 787 2700 7878 8854 8853 8...

result:

ok 

Test #44:

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

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:

235
82367 82368 47101 50048 50049 32813 59203 55043 55042 23728 23729 41656 6457 76844 76843 10501 23892 23891 23890 23889 68754 68753 62848 55083 85623 85622 38816 74251 44508 3743 64867 55909 15161 27898 20851 20850 3965 37767 57350 57351 4718 41975 70334 70333 44977 44976 41417 30888 30889 36632 ...

result:

ok 

Test #45:

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

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:

153
42496 42495 94799 94798 35794 79797 76889 76890 76891 31199 31200 88447 35788 57309 74936 3960 61616 73033 11544 11543 31370 31371 31372 12359 53270 95115 66211 43918 43917 43916 43915 43914 43913 43912 156 62707 22800 22799 41108 15975 15976 5036 25239 48068 73344 21465 21464 91481 22166 72949 ...

result:

ok 

Test #46:

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

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:

5
41621 4635 63396 63395 83346
117 84668 79428 79429 118

result:

ok 

Test #47:

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

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:

71
45952 41559 38843 38842 55108 55107 55106 52983 72729 72730 46495 46494 3685 94846 94845 57909 16054 16053 96159 96158 10581 10582 28697 86167 61083 61082 80168 36749 36748 34690 34689 83318 83317 29211 29212 29213 38581 38580 10372 10373 85330 54205 54204 59991 59992 50472 70447 67802 67803 6780...

result:

ok 

Test #48:

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

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:

27
38890 890 69783 67947 67948 70121 70120 23126 49933 32638 32639 32640 96852 43150 43151 43152 43153 35636 35637 3085 3086 80101 7346 7345 7344 38892 38891
65694 87506 87505 87504 78529 11547 15483 44045 44046 71043 38932 38931 38930 38929 3088 3087 84715 84716 31128 31127 59384 59383 59382 89801 ...

result:

ok 

Test #49:

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

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:

174
46073 33226 79991 32593 32592 55100 36742 74602 74601 68806 68807 91917 82245 82244 83010 91014 36182 36181 36180 63582 60187 25199 25200 732 14462 17801 17802 65469 65468 65467 94034 94033 20779 20780 79360 20404 20403 20402 63691 63690 52735 82268 82267 58364 58365 31974 66701 66700 66699 1232...

result:

ok 

Test #50:

score: 0
Accepted
time: 1ms
memory: 3572kb

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
2 6 7 3
6 2 1 5

result:

ok 

Test #51:

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

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:

120
47085 47084 6353 6352 6351 77422 54768 64284 76410 61477 62887 27893 20864 20863 20862 20861 56249 15835 15834 23599 23491 23492 23493 24971 24972 70962 70963 82718 82717 24213 55238 55239 34726 34727 34728 34729 34584 24949 69096 69097 69098 69099 16156 76349 95270 95271 95272 90255 54170 46810...

result:

ok 

Test #52:

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

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:

5
1 2 3 7 6
5 6 7 3 2

result:

ok 

Test #53:

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

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:

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

result:

ok 

Test #54:

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

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:

3
9 2 1
5 7 6

result:

ok 

Test #55:

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

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:

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

result:

ok 

Test #56:

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

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
6 5 2 1
2 5 6 9

result:

ok 

Test #57:

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

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:

4
2 1 4 5
4 1 2 3

result:

ok 

Test #58:

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

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
7 9 8
4 3 6

result:

ok 

Test #59:

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

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: 0ms
memory: 3804kb

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:

4
3 8 10 9
10 8 3 4

result:

ok 

Test #61:

score: 0
Accepted
time: 1ms
memory: 3692kb

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:

21
870 5 544 652 4 554 787 166 714 62 114 116 460 613 106 257 953 603 372 553 259
460 116 114 62 714 166 787 554 4 258 863 862 356 844 48 538 713 376 647 470 514

result:

ok 

Test #62:

score: 0
Accepted
time: 4ms
memory: 4540kb

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:

32
3476 9368 3217 9051 1607 9982 7808 594 8109 2519 3044 177 1501 4449 7352 4293 6128 7732 8931 5713 1856 9077 5105 7570 2484 6537 3725 9052 4812 1473 9219 3968
5397 3005 9984 3580 9436 1524 8664 261 9187 5119 8292 7315 9316 7370 5210 5134 4686 8886 2157 9599 7021 5844 6360 2040 7605 3330 9921 6212 ...

result:

ok 

Test #63:

score: 0
Accepted
time: 4ms
memory: 4656kb

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:

73
7621 8554 6423 9803 641 1434 7480 4209 5691 1666 1608 3202 6972 5355 8215 9926 9705 6638 267 5636 4373 4877 6819 5146 7156 5451 8306 8236 216 5977 6942 806 244 6848 7910 9726 1293 918 6994 5588 2480 1559 6375 4971 5621 1052 6601 5791 1789 5038 8260 768 3101 2171 3879 3611 281 520 3862 8137 237 30...

result:

ok 

Test #64:

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

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:

78
29618 58195 77070 70334 75425 63268 24687 14685 56951 4317 30261 74507 47552 71341 98513 7350 10886 17950 23147 11137 5829 63764 20362 86266 29896 31734 91509 84046 41291 32155 22927 67494 37213 98452 43929 71433 10401 22362 27950 26001 89781 29333 83043 79087 91419 37639 18447 38316 14318 35528 ...

result:

ok 

Test #65:

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

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:

113
7981 90810 18700 56192 80698 58932 85170 34494 67425 31976 50976 9291 84820 3465 28886 87713 31355 63906 45361 32062 48474 53265 36791 48513 42069 15495 79252 51464 61708 71687 54807 402 62611 83594 45252 63494 41497 34123 10487 53600 57792 1969 75401 65548 76994 13192 8954 90621 3059 7286 5645 ...

result:

ok 

Test #66:

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

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:

54
8200 97255 59774 89375 32362 77134 66296 50837 80888 86109 78465 49048 24859 75715 93802 23206 11820 47855 18713 37018 11037 56004 95505 83930 16890 23065 1138 55442 52281 63339 94217 22005 90701 71353 61158 10308 71580 24487 22012 29463 88808 10047 95824 68038 66357 3994 85624 38101 15781 23639 ...

result:

ok 

Test #67:

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

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:

133
77146 52627 84086 11998 62314 7623 98107 13458 65413 49156 56344 97968 18582 63751 31995 49372 44927 48848 31247 92291 1422 94824 11375 59793 80537 76152 79152 11120 91331 94579 9499 16794 22307 96533 78754 56227 66442 81567 77252 31784 20727 20834 39953 82090 1298 49517 66089 12409 40921 11333 ...

result:

ok 

Test #68:

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

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:

104
52508 31556 44629 96622 95581 92627 95646 35521 81801 59823 37173 99241 35919 8772 56323 52277 96248 22076 10654 36958 77859 38203 63318 15245 10727 23907 21253 1653 2892 77009 47548 81074 54498 95340 78447 92045 20276 61409 85278 56595 5095 93677 84907 23123 2282 21285 24245 23845 78755 69053 4...

result:

ok 

Test #69:

score: 0
Accepted
time: 34ms
memory: 17048kb

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:

109
19884 58853 9516 39458 90742 11156 95697 61663 43354 78538 66988 51908 21691 93533 90012 89440 89927 7932 4925 7007 90025 38354 40960 26160 728 46949 31114 84876 78994 85521 67722 81476 65724 74600 37885 91867 87210 25634 78208 50981 69381 34886 72736 26417 2238 360 18863 36358 39304 13424 68424...

result:

ok 

Test #70:

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

input:

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

output:

4
1 5 3 2
4 2 3 5

result:

ok 

Test #71:

score: 0
Accepted
time: 36ms
memory: 16584kb

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:

123
38506 24545 13111 51404 78950 71633 45140 21446 28928 13674 73138 50345 41833 57187 22934 44608 92102 78931 16762 62732 9367 17793 59392 75799 58769 75081 27841 6686 32932 57358 17483 36189 3175 29555 11697 46257 9598 31594 84405 80041 85375 52032 9850 77544 59042 59019 57547 72538 32979 3663 31...

result:

ok 

Test #72:

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

input:

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

output:

3
5 3 6
5 3 1

result:

ok 

Test #73:

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

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:

4
2 7 4 5
7 1 6 3

result:

ok 

Test #74:

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

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:

4
7 5 1 8
6 7 5 1

result:

ok 

Test #75:

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

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
9 2 4
8 4 5

result:

ok 

Test #76:

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

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:

4
6 10 9 8
4 3 8 7

result:

ok 

Test #77:

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

input:

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

output:

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

result:

ok 

Test #78:

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

input:

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

output:

5
4 10 9 8 3
2 3 8 9 10

result:

ok