QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#605429#8581. 섬Matutino27 5ms7708kbC++171.3kb2024-10-02 17:12:482024-10-02 17:12:49

Judging History

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

  • [2024-10-02 17:12:49]
  • 评测
  • 测评结果:27
  • 用时:5ms
  • 内存:7708kb
  • [2024-10-02 17:12:48]
  • 提交

answer

#include "island.h"
#include<bits/stdc++.h>
#define reg register
const int N=1e5+10;
int vis[N],d[N];
std::vector<int> G[N];
std::vector<std::array<int,2>> T1,T2;
std::map<std::pair<int,int>,bool> mp;
inline void add(reg int u,reg int v){G[u].push_back(v),G[v].push_back(u),d[u]++,d[v]++;}
void construct_two_trees(int n, std::vector<int> U, std::vector<int> V){
    for (reg int i=0;i<n-3;i++) mp[{U[i],V[i]}]=1,add(U[i],V[i]);
    for (reg int i=0;i<n;i++) add(i,(i+1)%n),mp[{i,(i+1)%n}]=1;
    reg int A,B,C; std::queue<int> q;
    for (reg int i=0;i<n;i++){
        reg int a=i,b=(i+1)%n,c=(i+2)%n;
        if (mp.count({a,c})||mp.count({c,a})){
            A=a,B=b,C=c,add_vertex(a,b,c);
            add(a,n),add(b,n),add(c,n);
            break;
        }
    }
    // std::cerr<<A<<" "<<B<<" "<<C<<"\n";
    for (reg int i=0;i<=n;i++) if (d[i]==2) q.push(i);
    while (!q.empty()){
        reg int u=q.front(),x=-1,y=-1; vis[u]=1,q.pop();
        // std::cerr<<"<< "<<u<<"\n";
        for (auto v:G[u]) if (!vis[v]) x>-1?y=v:x=v;
        assert(x>-1&&y>-1);
        if ((--d[x])==2) q.push(x); T1.push_back({u,x});
        if ((--d[y])==2) q.push(y); T2.push_back({u,y});  
    }
    T1.push_back({A,B}),T1.push_back({A,C}),T1.push_back({B,n});
    T2.push_back({B,C}),T2.push_back({A,n}),T2.push_back({C,n});
    report(T1),report(T2);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 1ms
memory: 6152kb

input:

4
0 2

output:

1
4
3 2
0 1
0 2
1 4
2
4
3 0
1 2
0 4
2 4
1
0 1 2

result:

ok Correct

Test #2:

score: 6
Accepted
time: 1ms
memory: 6436kb

input:

3

output:

1
3
0 1
0 2
1 3
2
3
1 2
0 3
2 3
1
0 1 2

result:

ok Correct

Test #3:

score: 6
Accepted
time: 1ms
memory: 6148kb

input:

4
3 1

output:

1
4
0 1
1 2
1 3
2 4
2
4
0 3
2 3
1 4
3 4
1
1 2 3

result:

ok Correct

Test #4:

score: 6
Accepted
time: 1ms
memory: 6444kb

input:

5
1 4
1 3

output:

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

result:

ok Correct

Subtask #2:

score: 0
Runtime Error

Test #5:

score: 8
Accepted
time: 1ms
memory: 6300kb

input:

10
7 0
7 5
7 3
7 1
7 9
7 4
7 2

output:

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

result:

ok Correct

Test #6:

score: 8
Accepted
time: 2ms
memory: 6884kb

input:

1000
10 919
10 561
10 671
10 430
10 425
10 987
10 608
10 401
10 467
10 850
10 207
10 99
10 864
10 907
10 590
10 410
10 3
10 236
10 546
10 455
10 694
10 651
10 193
10 295
10 910
10 929
10 151
10 157
10 869
10 453
10 587
10 800
10 988
10 832
10 7
10 723
10 172
10 628
10 432
10 527
10 702
10 328
10 895...

output:

1
1000
11 10
12 10
13 10
14 10
15 10
16 10
17 10
18 10
19 10
20 10
21 10
22 10
23 10
24 10
25 10
26 10
27 10
28 10
29 10
30 10
31 10
32 10
33 10
34 10
35 10
36 10
37 10
38 10
39 10
40 10
41 10
42 10
43 10
44 10
45 10
46 10
47 10
48 10
49 10
50 10
51 10
52 10
53 10
54 10
55 10
56 10
57 10
58 10
59 10...

result:

ok Correct

Test #7:

score: 8
Accepted
time: 2ms
memory: 7708kb

input:

5000
3653 4458
3653 4383
3653 1303
3653 3306
3653 3218
3653 2614
3653 4321
3653 959
3653 2749
3653 3926
3653 3679
3653 2498
3653 163
3653 1980
3653 3542
3653 1300
3653 4388
3653 4971
3653 3012
3653 711
3653 103
3653 3179
3653 4304
3653 4387
3653 1526
3653 4202
3653 3989
3653 810
3653 4756
3653 4029
...

output:

1
5000
3654 3653
3655 3653
3656 3653
3657 3653
3658 3653
3659 3653
3660 3653
3661 3653
3662 3653
3663 3653
3664 3653
3665 3653
3666 3653
3667 3653
3668 3653
3669 3653
3670 3653
3671 3653
3672 3653
3673 3653
3674 3653
3675 3653
3676 3653
3677 3653
3678 3653
3679 3653
3680 3653
3681 3653
3682 3653
368...

result:

ok Correct

Test #8:

score: 0
Runtime Error

input:

199999
98281 193703
98281 79970
98281 92443
98281 1621
98281 144687
98281 143302
98281 15416
98281 9245
98281 127092
98281 21325
98281 149110
98281 119923
98281 53885
98281 25820
98281 29852
98281 34700
98281 120142
98281 185421
98281 84923
98281 66458
98281 192051
98281 44169
98281 114692
98281 105...

output:

Unauthorized output

result:


Subtask #3:

score: 0
Runtime Error

Test #10:

score: 14
Accepted
time: 0ms
memory: 7188kb

input:

5000
4593 3389
4593 1610
4593 2357
4593 3323
4593 2037
4593 3667
4593 2737
4593 2642
4593 3981
4593 2700
4593 2134
4593 1719
4593 1444
4593 3729
4593 1371
4593 546
4593 1249
4593 646
4593 4221
4593 1542
4593 2314
4735 4952
4593 680
4593 2555
4593 2152
4593 740
4593 4056
4593 64
4593 3079
4593 3021
4...

output:

1
5000
4951 4950
4950 4952
4949 4952
4948 4952
4947 4952
4946 4952
4945 4952
4944 4952
4943 4952
4942 4952
4941 4952
4940 4952
4939 4952
4938 4952
4937 4952
4936 4952
4935 4952
4934 4952
4933 4952
4932 4952
4931 4952
4930 4952
4929 4952
4928 4952
4927 4952
4926 4952
4925 4952
4924 4952
4923 4952
492...

result:

ok Correct

Test #11:

score: 14
Accepted
time: 4ms
memory: 7192kb

input:

5000
2039 2601
4753 3413
4753 4178
4753 3835
1179 2601
4753 3353
1382 2601
2310 2378
4753 3219
716 2601
1380 2601
4753 2757
4753 3561
4753 4236
4753 3289
1043 2601
4753 4154
4753 3226
144 2601
1791 2601
4753 3407
670 2601
685 2601
2217 2601
2310 2466
4753 3885
4753 3911
4753 3916
1999 2601
1057 2601...

output:

1
5000
4752 4751
4751 4753
4750 4753
4749 4753
4748 4753
4747 4753
4746 4753
4745 4753
4744 4753
4743 4753
4742 4753
4741 4753
4740 4753
4739 4753
4738 4753
4737 4753
4736 4753
4735 4753
4734 4753
4733 4753
4732 4753
4731 4753
4730 4753
4729 4753
4728 4753
4727 4753
4726 4753
4725 4753
4724 4753
472...

result:

ok Correct

Test #12:

score: 14
Accepted
time: 5ms
memory: 7496kb

input:

5000
3821 2308
3611 2536
3156 2615
4013 879
3821 1271
3252 2615
4235 4538
4235 527
3611 2504
4021 879
3821 2074
3821 1764
3821 2264
4235 4702
3821 1358
3821 1419
3821 1031
3821 2008
4145 879
3821 1756
3821 947
4235 532
3989 879
2882 2615
3821 1502
4235 338
4232 879
3821 1280
3621 2310
4235 4997
4235...

output:

1
5000
4236 4235
4237 4235
4238 4235
4239 4235
4240 4235
4241 4235
4242 4235
4243 4235
4244 4235
4245 4235
4246 4235
4247 4235
4248 4235
4249 4235
4250 4235
4251 4235
4252 4235
4253 4235
4254 4235
4255 4235
4256 4235
4257 4235
4258 4235
4259 4235
4260 4235
4261 4235
4262 4235
4263 4235
4264 4235
426...

result:

ok Correct

Test #13:

score: 14
Accepted
time: 2ms
memory: 7520kb

input:

5000
4291 1887
492 668
4405 1768
424 732
520 636
511 652
3249 2930
281 883
3798 2370
4497 1684
4314 1862
4589 1587
4128 2056
518 643
407 747
3666 2530
3911 2240
3656 2549
3804 2367
3221 2967
3340 2850
4644 1521
4696 1470
337 830
3200 3002
4958 1227
3690 2499
4052 2120
4584 1590
3454 2726
259 898
386...

output:

1
5000
3102 3101
3101 3103
3103 3100
3104 3100
3100 3105
3099 3105
3098 3105
3105 3097
3106 3097
3097 3107
3096 3107
3095 3107
3107 3094
3094 3108
3108 3093
3109 3093
3093 3110
3092 3110
3110 3091
3091 3111
3090 3111
3089 3111
3088 3111
3087 3111
3111 3086
3112 3086
3113 3086
3114 3086
3115 3086
308...

result:

ok Correct

Test #14:

score: 0
Runtime Error

input:

200000
118877 111067
118877 61677
118877 152911
118877 27918
118877 37129
118877 191189
134624 141257
118877 61841
118877 148131
118877 21099
118877 143149
118877 156253
118877 45282
118877 150038
118877 161995
118877 46438
118877 89345
118877 145634
118877 47579
118877 97199
118877 190418
131092 14...

output:

Unauthorized output

result:


Subtask #4:

score: 21
Accepted

Dependency #1:

100%
Accepted

Test #19:

score: 21
Accepted
time: 1ms
memory: 6112kb

input:

10
0 2
6 0
4 2
0 5
6 9
6 8
0 4

output:

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

result:

ok Correct

Test #20:

score: 21
Accepted
time: 0ms
memory: 7468kb

input:

4999
3847 3851
3126 3142
1188 300
4756 4752
526 484
928 930
3288 3297
1628 1603
2089 2091
2619 2643
2471 2481
1709 1718
1222 1266
3245 3235
31 35
3009 3306
4609 4612
3366 3362
3715 3813
550 545
630 692
3581 3584
3715 3713
747 743
1191 1205
4289 4286
469 467
3879 3876
168 170
520 518
1890 1888
4515 4...

output:

1
4999
3 2
6 5
8 7
10 9
13 12
16 15
20 19
22 21
25 24
29 28
32 31
38 37
40 39
42 41
44 43
46 45
48 47
50 49
53 52
56 55
58 57
61 60
64 63
66 65
70 69
73 72
75 74
77 76
79 78
82 81
84 83
86 85
88 87
90 89
93 92
95 94
99 98
101 100
105 104
107 106
111 110
113 112
116 115
118 117
120 119
122 121
124 12...

result:

ok Correct

Test #21:

score: 21
Accepted
time: 5ms
memory: 7480kb

input:

5000
2923 2920
2307 2310
4952 4949
4327 4246
2332 2323
3794 3798
2344 2346
2927 2924
4437 4439
4529 4531
2634 2630
1847 1852
542 538
4607 4599
1011 1013
4696 4694
287 284
814 782
524 527
1362 1359
2558 2560
1095 1097
1432 1485
158 161
2395 2401
4738 4755
1481 1483
1044 1041
644 642
1122 1116
4341 43...

output:

1
5000
0 1
4 3
6 5
8 7
12 11
15 14
18 17
20 19
24 23
26 25
29 28
32 31
35 34
37 36
39 38
41 40
43 42
45 44
49 48
52 51
55 54
57 56
59 58
61 60
65 64
67 66
71 70
73 72
75 74
78 77
83 82
85 84
87 86
89 88
93 92
96 95
100 99
105 104
107 106
109 108
112 111
114 113
116 115
120 119
123 122
125 124
128 12...

result:

ok Correct

Test #22:

score: 21
Accepted
time: 5ms
memory: 7244kb

input:

4999
149 145
4651 4684
3354 3392
3453 3457
4314 4305
1036 1039
4915 4918
4229 4223
4554 4558
4176 4179
376 372
509 525
1057 1051
3361 3363
2724 2713
664 658
1608 1619
80 78
2040 2042
550 555
2126 2131
169 171
1590 1592
4593 4601
409 411
4863 4860
1306 1304
2177 2175
4770 4787
4981 4984
1225 1075
385...

output:

1
4999
3 2
6 5
11 10
15 14
17 16
20 19
23 22
26 25
28 27
30 29
32 31
34 33
36 35
39 38
41 40
43 42
45 44
47 46
49 48
51 50
55 54
57 56
60 59
62 61
65 64
67 66
69 68
71 70
73 72
75 74
79 78
82 81
84 83
86 85
89 88
92 91
96 95
101 100
103 102
105 104
107 106
109 108
113 112
115 114
117 116
120 119
122...

result:

ok Correct

Test #23:

score: 21
Accepted
time: 2ms
memory: 7272kb

input:

5000
2054 2060
853 855
4655 4664
3349 3343
1871 1867
1136 1134
521 525
1263 1261
1885 1874
3482 3479
1857 1844
2878 2873
1588 1590
4648 4643
1737 1735
1414 1410
668 665
4673 4691
2404 2402
1198 1200
2559 2554
2287 2291
3284 3277
775 773
2763 2761
1550 1563
277 279
3249 3255
2689 2678
1167 1165
2886 ...

output:

1
5000
3 2
6 5
8 7
10 9
12 11
16 15
18 17
20 19
23 22
25 24
27 26
30 29
32 31
35 34
38 37
40 39
42 41
44 43
46 45
50 49
54 53
56 55
58 57
60 59
62 61
66 65
68 67
70 69
73 72
76 75
79 78
81 80
84 83
86 85
88 87
90 89
92 91
94 93
98 97
101 100
103 102
105 104
107 106
109 108
111 110
113 112
115 114
11...

result:

ok Correct

Test #24:

score: 21
Accepted
time: 5ms
memory: 7504kb

input:

5000
866 197
4394 4396
156 158
1432 2482
2027 2242
1097 4080
4028 4030
4213 1069
824 408
1199 3552
270 272
923 4965
3383 3385
79 81
1438 2456
781 596
1587 2335
1381 2698
1206 3524
2888 1335
3134 1290
1968 1970
2665 2667
143 882
2633 2635
3957 3959
1163 3790
3596 3598
644 774
2318 1643
1670 1672
1447...

output:

1
5000
0 1
5 4
8 7
10 9
13 12
15 14
18 17
21 20
24 23
27 26
29 28
31 30
33 32
38 37
40 39
42 41
44 43
47 46
50 49
54 53
56 55
60 59
62 61
64 63
67 66
69 68
72 71
74 73
76 75
78 77
80 79
82 81
84 83
87 86
89 88
91 90
96 95
98 97
101 100
103 102
105 104
109 108
111 110
113 112
115 114
117 116
119 118
...

result:

ok Correct

Test #25:

score: 21
Accepted
time: 5ms
memory: 7216kb

input:

5000
719 761
3798 3828
4884 4895
3424 3426
3317 3319
1016 642
2578 2636
1536 1528
3047 3045
74 93
4626 4629
366 371
3317 3315
4741 4746
4826 4831
3207 3205
743 745
2151 2172
4022 503
4095 4097
1421 1414
4580 4578
3682 521
814 833
4300 4298
2974 2994
4194 4215
1477 1474
3507 3509
1084 1102
4884 4894
...

output:

1
5000
7 6
10 9
13 12
15 14
18 17
21 20
23 22
27 26
32 31
35 34
38 37
40 39
42 41
45 44
50 49
53 52
57 56
62 61
64 63
66 65
68 67
70 69
72 71
75 74
78 77
80 79
82 81
84 83
87 86
89 88
94 93
97 96
99 98
101 100
103 102
109 108
111 110
113 112
117 116
119 118
122 121
124 123
126 125
130 129
132 131
13...

result:

ok Correct

Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%