QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#949547#9038. Basic Graph AlgorithmhxsjAC ✓519ms121640kbC++142.7kb2025-03-24 01:52:502025-03-24 01:52:51

Judging History

This is the latest submission verdict.

  • [2025-03-24 01:52:51]
  • Judged
  • Verdict: AC
  • Time: 519ms
  • Memory: 121640kb
  • [2025-03-24 01:52:50]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
//using i128 = __int128;
#define sz(a) (int)(a.size())
#define rep(x,a,b) for(int x = a; x < b; x++)
#define all(a) a.begin(), a.end()
#define uni(a) a.resize(unique(all(a)) - a.begin())
#define maxe(a) max_element(all(a))
#define mine(a) min_element(all(a))
#define lb(b,val) lower_bound(b.begin(), b.end(), val) - b.begin()
#define ub(b,val) upper_bound(b.begin(), b.end(), val) - b.begin()
#define fd(b,val) find(all(b), val) - b.begin()
#define ct(b,val) count(all(b), val)
#define bp(s) __builtin_popcountll(s)
#define fi first 
#define se second
#define pb push_back
#define eb emplace_back
#define endl "\n"
#define sp setprecision
const int mod = 1e9 + 7;
struct DSU{
    vector<int> f, siz;
    DSU(int n) : f(n), siz(n, 1)
    {
        iota(f.begin(), f.end(), 0);
    }
    int find(int x)
    {
        return x == f[x] ? x : f[x] = find(f[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void merge(int x, int y)
    {
        x = find(x), y = find(y);
        if (x != y)
        {
            siz[x] += siz[y];
            f[y] = x;
        }
    }
    int size(int x)
    {
        return siz[find(x)];
    }
};
void solve(){
    int n, m, u, v;
    cin >> n >> m;
    vector<int> p(n + 1), st(n + 1), a(n + 1), id(n + 1);
    set<int> g[n + 1];
    DSU dsu(n + 1);
    vector<array<int, 2>> res, ed(m + 1);
    rep(i, 1, m + 1){
        cin >> ed[i][0] >> ed[i][1];
    }
    for(int i = 1; i <= n; i++){
        cin >> p[i];
        a[p[i]] = i;
        id[i] = p[i];
    }
    rep(i, 1, m + 1){
        u = ed[i][0];
        v = ed[i][1];
        g[a[u]].insert(a[v]);
        g[a[v]].insert(a[u]);
        dsu.merge(a[u], a[v]);
    }
    int idx = 1;
    int now = 0;
    function<void(int, int)> dfs = [&](int u, int f){
        st[u] = 1;
        //cout << id[u] << endl;
        now++;
        if(idx > n) return;
        if(idx == u) idx++;
        for(auto v : g[u]){
            if(st[v]) continue;
            if(v == idx){
                dfs(v, u);         
            }      
            else{
                res.pb({id[u], id[idx]});
                idx++;
                dfs(idx - 1, u);           
                dfs(u, f);         
            } 
        }
    };
    rep(i, 1, n + 1){
        now = 0;
        if(!st[i]) dfs(i, 0);
    }
    cout << sz(res) << endl;
    for(auto [x, y] : res) cout << x << " " << y << endl;
}
signed main(){
    int _ = 1;
    ios::sync_with_stdio(0);cin.tie(0),cout.tie(0);
    while(_--){
        solve();
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

2
1 2
3 5

result:

ok 

Test #2:

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

input:

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

output:

4
1 8
8 5
5 4
4 2

result:

ok 

Test #3:

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

input:

1 0
1

output:

0

result:

ok 

Test #4:

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

input:

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

output:

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

result:

ok 

Test #5:

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

input:

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

output:

5
2 6
5 4
4 10
10 3
8 1

result:

ok 

Test #6:

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

input:

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

output:

1
7 5

result:

ok 

Test #7:

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

input:

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

output:

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

result:

ok 

Test #8:

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

input:

100 80
72 24
14 74
69 100
86 37
55 17
54 29
48 66
34 75
68 36
97 71
51 68
12 86
60 10
77 23
64 68
77 50
61 98
11 72
40 88
11 12
68 35
27 33
81 28
78 50
37 71
28 20
22 17
59 4
98 30
17 87
42 8
36 43
96 47
12 17
44 47
33 41
55 49
62 76
39 69
27 35
100 61
52 85
91 41
31 69
18 30
3 41
45 35
3 56
27 47
1...

output:

93
61 46
61 15
61 64
64 37
37 51
51 3
3 31
31 91
91 89
91 18
18 99
18 41
41 86
86 52
52 100
100 78
78 44
44 48
48 7
7 85
7 24
24 2
24 16
16 83
16 68
68 63
68 95
68 94
35 80
35 56
56 98
98 82
82 50
50 67
50 43
43 38
38 9
9 62
62 1
62 19
19 26
19 96
96 76
96 59
59 5
5 23
23 72
72 47
47 79
47 22
22 45
...

result:

ok 

Test #9:

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

input:

100 200
26 97
59 71
17 1
66 52
51 58
59 76
26 23
96 91
29 32
60 61
85 34
71 4
33 99
73 76
80 63
11 31
69 84
24 17
62 15
22 73
98 44
59 41
54 70
8 34
1 81
97 87
99 14
14 41
6 47
64 49
44 60
70 26
15 11
72 98
68 46
8 19
76 79
31 62
90 98
63 71
36 44
79 19
84 34
65 56
100 59
63 58
19 93
14 59
87 72
38 ...

output:

95
6 34
34 46
46 57
57 75
75 32
32 59
59 37
37 10
10 47
47 23
23 9
9 39
39 52
52 77
77 29
29 58
58 38
38 55
55 73
73 1
1 88
88 54
54 80
80 4
4 79
79 99
99 51
51 94
94 92
92 14
14 87
87 90
90 95
95 25
25 93
93 11
11 97
97 85
85 81
81 40
81 66
66 89
89 100
100 12
12 42
42 63
63 18
18 96
96 68
68 19
19...

result:

ok 

Test #10:

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

input:

100 200
9 30
52 46
12 26
6 60
77 50
43 14
97 96
84 100
31 44
35 36
47 63
12 72
98 22
95 15
67 53
57 60
96 39
33 98
19 60
43 81
31 66
65 63
88 68
97 80
43 2
53 38
39 15
64 17
85 46
62 56
73 6
3 98
95 69
40 38
3 44
80 44
57 90
33 94
74 65
25 100
37 12
74 88
94 42
34 6
46 5
50 26
99 1
96 76
69 91
33 45...

output:

30
63 77
77 53
3 4
4 12
50 47
47 51
96 20
20 15
78 39
39 74
64 48
64 9
9 10
35 32
32 71
71 40
40 89
89 99
72 76
72 36
72 8
37 100
10 11
10 19
10 55
10 79
10 92
10 49
10 18
10 23

result:

ok 

Test #11:

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

input:

1000 100
343 745
296 856
507 192
780 459
9 193
753 28
334 871
589 105
612 751
708 129
32 628
974 641
323 596
604 759
906 272
606 898
726 304
279 448
589 565
735 53
935 966
424 363
153 900
722 597
501 125
512 282
744 460
529 488
67 895
407 863
59 984
211 458
578 461
999 10
411 521
738 842
689 160
168...

output:

987
153 751
751 393
751 544
751 333
751 90
751 755
751 386
751 740
751 920
751 64
64 11
11 842
842 916
842 962
842 147
842 938
842 896
842 417
842 928
928 388
928 708
708 903
708 813
813 391
813 925
813 126
813 519
813 311
813 408
813 698
813 880
813 4
813 413
813 966
966 455
966 223
966 710
966 621...

result:

ok 

Test #12:

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

input:

1000 1200
777 691
410 649
242 193
15 664
533 332
552 662
890 398
375 255
357 410
216 311
597 410
974 555
494 290
478 880
944 898
274 114
117 815
7 303
687 242
687 418
760 359
272 400
383 96
540 214
730 80
263 641
183 241
12 652
873 838
776 414
241 721
165 217
723 302
985 556
397 566
588 642
59 806
1...

output:

989
946 103
103 628
628 356
356 814
356 20
20 137
137 659
659 618
659 9
659 663
663 478
478 650
650 845
845 352
352 653
653 866
653 175
175 847
175 882
882 680
680 202
680 142
142 609
609 105
105 367
367 448
448 331
331 169
169 534
534 47
47 234
234 69
69 438
438 279
279 908
279 770
770 873
873 546
...

result:

ok 

Test #13:

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

input:

1000 1200
908 954
641 1
645 238
250 448
852 614
44 625
942 160
400 955
277 920
801 683
318 701
727 545
124 695
958 260
91 567
660 258
925 591
270 633
873 909
171 937
727 21
224 368
213 756
314 92
333 54
735 276
884 576
878 984
893 454
250 12
884 399
867 489
468 260
908 196
833 453
446 678
983 491
74...

output:

84
956 261
261 837
837 919
984 76
984 280
493 938
938 187
74 216
216 693
216 97
97 751
751 193
128 428
128 895
128 950
128 953
128 801
387 794
387 335
159 346
159 366
387 466
991 14
991 236
991 42
991 479
991 228
991 974
991 559
991 761
991 825
991 590
991 554
991 869
991 424
991 965
991 215
991 63
...

result:

ok 

Test #14:

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

input:

1000 3000
356 124
280 416
186 64
318 228
597 563
890 984
826 763
64 122
840 769
2 109
763 15
279 184
89 1000
191 549
656 24
464 946
582 88
900 411
304 964
993 142
612 276
351 197
766 686
94 696
671 402
541 1000
729 669
876 125
748 215
659 409
789 845
520 11
330 903
342 310
567 443
72 959
907 520
210...

output:

986
502 907
907 66
66 862
862 888
888 632
632 510
510 394
394 154
154 727
727 505
505 226
226 612
612 626
626 471
471 693
693 860
860 411
411 519
519 881
881 486
486 157
157 284
284 974
974 63
63 122
122 940
940 987
987 604
604 630
630 243
243 563
563 432
432 439
439 393
393 247
247 556
556 925
925 ...

result:

ok 

Test #15:

score: 0
Accepted
time: 142ms
memory: 40380kb

input:

100000 150000
96892 28186
36646 86342
39732 98411
34908 56085
40901 62329
67662 30883
44052 26992
76148 68860
66510 89248
17708 61845
76482 24252
31382 49506
96707 37054
16825 95166
98087 66209
58172 55942
93866 96934
37485 47902
24940 45904
35198 85130
52495 90472
88450 69654
602 22713
90741 2639
4...

output:

99982
96842 89893
89893 19974
19974 60343
60343 1606
1606 32704
32704 99522
99522 81888
81888 50337
50337 8035
8035 4567
4567 71447
71447 60034
60034 1986
60034 42800
42800 82285
82285 64268
64268 20149
20149 6396
6396 30315
30315 8656
8656 37885
37885 71586
71586 95569
95569 69568
69568 84402
84402...

result:

ok 

Test #16:

score: 0
Accepted
time: 180ms
memory: 45632kb

input:

100000 200000
76254 3366
37155 63474
21986 10015
51756 81588
4298 60367
62502 97801
80559 14424
15996 57429
35409 42206
40865 3901
21843 78280
56617 83754
19581 89571
29293 55245
67066 16959
92619 82741
79224 98864
54468 72666
51594 27918
76029 42646
90761 95093
95678 56007
50895 12934
76406 89871
6...

output:

99988
2583 30072
30072 23100
23100 85580
85580 43887
43887 92817
92817 97996
97996 14803
14803 13396
13396 35665
35665 72494
72494 34596
34596 84986
84986 77345
77345 62190
62190 36508
36508 64136
64136 61054
61054 1893
1893 7231
7231 58787
58787 59356
59356 43311
43311 74850
74850 86046
86046 9670
...

result:

ok 

Test #17:

score: 0
Accepted
time: 166ms
memory: 39168kb

input:

100000 200000
11902 24760
6635 30308
38746 66284
6089 42413
98863 23831
85821 61232
52229 21272
18144 237
96939 33617
33458 26185
40657 15304
14327 80524
6540 99719
27861 29602
50197 10877
33527 49530
51339 14715
62829 96106
34380 91768
68106 85064
22784 7310
67045 8210
4910 74138
97816 21896
8453 7...

output:

3
60101 76838
76838 77590
80901 25172

result:

ok 

Test #18:

score: 0
Accepted
time: 148ms
memory: 40704kb

input:

100000 200000
19309 97247
90804 33186
61543 98979
67630 74407
8112 12777
22990 87914
51923 97452
97609 64864
3951 41053
5736 16403
48245 59007
50246 85728
10125 681
71957 71128
83314 37543
4057 65826
88369 94042
59115 74615
42191 68179
77175 66053
16416 13116
61054 95245
97168 94191
28437 4710
57598...

output:

10499
31608 84286
31608 65058
89639 65023
65023 53800
286 16908
16908 16501
99823 49777
49777 49581
50370 27710
75266 44896
44896 7919
88699 76094
88699 74214
19405 45491
45491 60162
21418 80225
80225 20636
44132 21400
44132 26433
12218 83262
12218 86146
23879 55273
55273 81695
80972 8348
8348 27578...

result:

ok 

Test #19:

score: 0
Accepted
time: 147ms
memory: 40448kb

input:

100000 200000
91576 90182
572 73347
22410 47653
44985 48965
80374 1826
98618 19771
56735 64161
59312 69703
29856 50044
56444 3451
33027 95872
76598 10846
6731 30896
87751 54382
44812 22145
92623 91097
42893 64221
6400 32418
16621 51712
2464 60610
67867 52190
44331 93925
94429 19675
82864 97897
19626...

output:

12306
64970 28821
28821 39407
2242 73580
73580 90351
15396 99848
99848 61577
35678 65807
65807 49695
47107 56845
56845 669
58280 64560
64560 8064
4422 57946
57946 88658
90898 94515
94515 11314
28144 59532
59532 55251
96651 30531
30531 81623
33079 29646
29646 54350
47906 80267
80267 6804
48964 62162
...

result:

ok 

Test #20:

score: 0
Accepted
time: 23ms
memory: 24448kb

input:

300000 0
239415 50154 20266 131115 94234 36028 102103 163828 247232 288414 191935 70446 292328 101071 278663 149866 15685 291862 236268 78373 298325 130058 200948 182893 276807 219715 33136 269040 46221 48212 250438 121345 179565 46706 177889 240176 94461 152264 78126 50364 161649 258824 265439 2036...

output:

0

result:

ok 

Test #21:

score: 0
Accepted
time: 62ms
memory: 70192kb

input:

300000 1000
176327 123454
108805 134687
10949 281116
76366 262705
295845 217355
254150 209599
10192 25335
179488 163661
188961 237531
26754 145298
48650 219114
60296 186619
159919 71306
132480 121958
190633 91092
34925 178056
46276 15190
118693 158760
14177 189841
267955 169761
22517 11162
241301 19...

output:

299928
182471 116476
182471 18786
182471 63210
182471 128598
182471 234774
182471 242940
182471 3762
182471 191843
182471 86043
182471 255888
182471 233009
182471 209477
182471 215744
182471 26398
182471 245351
182471 118668
182471 4942
182471 43873
182471 112368
182471 263390
182471 210648
182471 2...

result:

ok 

Test #22:

score: 0
Accepted
time: 499ms
memory: 121596kb

input:

300000 500000
130853 77986
268278 149627
139155 276340
106860 133524
51023 11369
161453 287568
206782 237267
279169 11634
75079 289989
9969 146145
30871 226971
20651 50825
109278 41647
135810 14201
52112 226533
1580 268452
277222 40224
97186 36416
170778 147018
83811 129161
267150 105328
71345 19855...

output:

299984
142405 140596
140596 74200
74200 22486
22486 196976
196976 140823
140823 24270
24270 55376
55376 133749
133749 151234
151234 227752
227752 285145
227752 106282
106282 119441
119441 288899
288899 30979
30979 57910
57910 192652
192652 43923
43923 99418
99418 35027
35027 103828
103828 138654
138...

result:

ok 

Test #23:

score: 0
Accepted
time: 519ms
memory: 121584kb

input:

300000 500000
246981 159534
148831 211809
88408 155117
211547 17512
185178 215552
221893 280015
139576 96404
140980 83743
146993 237548
107987 186194
294620 207452
28161 125209
23135 184560
130031 263254
66425 226403
20806 11426
52217 183656
123487 39528
272804 244389
171048 295080
7443 123443
37126...

output:

299986
6142 130971
130971 114865
114865 42177
42177 202386
202386 158398
158398 166011
166011 193708
193708 12492
12492 29745
29745 278587
278587 14643
14643 183776
183776 47032
183776 89516
89516 1185
1185 141319
141319 134784
134784 25303
25303 871
871 81333
81333 287139
287139 186901
186901 71336...

result:

ok 

Test #24:

score: 0
Accepted
time: 512ms
memory: 121640kb

input:

300000 500000
97701 284187
286281 141286
204958 25382
183530 201500
152038 287030
115036 182863
239666 165941
11303 164364
94716 9298
38709 183139
215264 55230
202966 191080
202400 194768
291549 255411
248033 260865
164224 88992
37612 27089
25595 201424
40238 174464
90990 285191
56248 184661
135611 ...

output:

299984
4007 191584
191584 149314
149314 122407
122407 260064
260064 138725
138725 40984
40984 69377
40984 4859
4859 262030
262030 59229
59229 292097
292097 188774
292097 288031
288031 90040
90040 224652
224652 280938
280938 32565
32565 106896
106896 114483
114483 9677
9677 249544
249544 194774
19477...

result:

ok 

Test #25:

score: 0
Accepted
time: 427ms
memory: 97092kb

input:

300000 500000
1198 16305
102765 78814
211589 288237
227329 119702
86036 52640
236373 172597
24721 158329
2108 31063
221704 222013
213017 177642
243737 96197
149384 197520
200663 282109
189750 131041
261034 137351
122884 172902
161230 233718
200935 102559
255186 290067
257739 145790
76666 106172
3153...

output:

7
68292 167562
167562 156824
156824 191707
191707 148411
191707 194123
188212 109028
188212 126770

result:

ok 

Test #26:

score: 0
Accepted
time: 443ms
memory: 100168kb

input:

300000 500000
200302 154786
138771 186325
192924 94832
196350 88358
288066 269369
10836 254676
90490 174462
31784 246923
226386 226038
137794 75821
55627 95820
55229 186541
288795 164158
290826 146165
237196 12640
191276 165600
140795 172855
66267 299872
83705 177663
6689 16633
289453 89030
35871 10...

output:

31562
49212 31687
31687 268320
118477 122536
122536 54960
278513 134663
134663 123330
31430 219963
31430 218880
273245 65513
65513 121524
269767 183490
269767 219550
219550 148475
148475 234009
116132 247572
116132 69901
181513 197688
197688 126029
197688 190292
197688 137551
197688 194763
197688 13...

result:

ok 

Test #27:

score: 0
Accepted
time: 442ms
memory: 97480kb

input:

300000 500000
59228 247000
34656 137006
118179 241031
252463 106642
278400 16205
13102 93414
76650 78885
196743 123592
160348 6895
254088 37050
124981 87312
168352 204098
262457 101264
85542 89130
82765 221562
211538 12481
278014 76063
188034 240248
108667 91411
103831 170981
225815 146031
144693 12...

output:

19353
175661 226513
226513 181507
140861 32103
32103 45317
232071 297664
297664 21461
154201 194013
194013 23529
80779 210324
210324 296615
183568 241087
241087 135454
28362 47664
47664 261637
246678 288630
288630 22805
87595 265319
265319 128059
272559 268899
268899 128238
128238 54978
206272 70081...

result:

ok 

Test #28:

score: 0
Accepted
time: 449ms
memory: 99608kb

input:

300000 500000
234151 39186
130579 106071
116572 162320
184234 262378
107242 19515
19913 276379
80453 139986
157441 207506
76792 147047
11189 28236
191073 152576
27068 231930
289680 227769
236419 22848
118412 248288
249224 66198
77421 18136
73536 266794
256195 90743
275185 148541
287022 147623
53081 ...

output:

32274
180001 272678
272678 295755
295501 127514
127514 125003
113074 145101
145101 192211
153124 277139
277139 178791
44431 18292
18292 263032
129551 41336
41336 222000
269219 280139
280139 219899
144818 242623
144818 148356
254331 269364
254331 297173
134095 292510
292510 69817
240280 105074
105074...

result:

ok 

Test #29:

score: 0
Accepted
time: 301ms
memory: 101328kb

input:

300000 300000
22868 55660
80999 67752
256726 138526
49443 169022
263413 214166
259034 111575
102286 290360
198685 81339
68742 272558
164706 2098
77860 14817
29025 236429
21233 47364
161079 158491
257567 31338
72678 97588
68159 49131
133555 248594
202185 64835
250823 172691
228600 60819
53199 167545
...

output:

299985
49948 23153
23153 59091
59091 163644
163644 249893
249893 101270
101270 233221
101270 72552
101270 97517
97517 206910
206910 55404
206910 5760
5760 256456
256456 168126
168126 68829
68829 54928
54928 190452
190452 146026
146026 81824
81824 15500
15500 232356
232356 134087
134087 262622
262622...

result:

ok 

Test #30:

score: 0
Accepted
time: 307ms
memory: 101328kb

input:

300000 300000
6292 171801
85745 254126
205980 184599
145618 53010
230272 118348
152178 138615
35081 192602
25904 29256
149169 52820
228132 166339
41608 295299
36534 178108
67794 190277
22596 107544
14983 31208
91904 7859
186258 192564
159856 243194
269619 294910
38061 162802
144701 246230
186276 234...

output:

299988
145528 80534
145528 272614
272614 220667
220667 118896
220667 239682
239682 195568
195568 108304
108304 140678
140678 113895
140678 165985
165985 288856
288856 272140
272140 34482
272140 163474
163474 240415
240415 278204
240415 109972
240415 299527
299527 109711
109711 158888
158888 293428
2...

result:

ok 

Test #31:

score: 0
Accepted
time: 305ms
memory: 101304kb

input:

300000 300000
289716 253349
99002 183604
31041 187568
117602 69702
64428 22530
212617 298358
135171 86331
63523 277173
221083 124570
26150 39092
138061 18885
211339 76683
105843 200485
149521 99701
162000 241479
235322 93937
295845 168700
194669 113603
71645 224985
125298 20208
184994 140152
160569 ...

output:

299986
231499 264672
264672 252003
252003 41314
252003 97265
97265 148609
148609 34081
34081 207455
34081 189643
189643 64431
64431 145005
145005 208446
208446 158651
158651 284853
284853 60083
60083 290183
290183 168013
168013 170877
170877 129515
129515 195245
195245 238831
238831 262639
238831 21...

result:

ok 

Test #32:

score: 0
Accepted
time: 246ms
memory: 66428kb

input:

300000 300000
142243 117798
53723 10656
143613 187222
286260 166119
199253 152459
140403 7759
128887 130180
150095 169619
184710 37620
84758 286815
227674 3075
128968 209078
294045 210381
146905 259885
264685 218177
3315 111789
296222 64259
216594 95380
64565 33674
178406 205717
250861 281282
9364 3...

output:

42572
236018 180840
236018 34199
34199 182333
34199 258304
34199 236964
34199 239687
34199 135311
34199 255945
34199 198866
34199 139322
34199 223210
34199 145134
34199 175496
34199 3364
34199 282301
34199 27434
34199 65864
34199 227204
34199 118984
34199 253890
34199 225467
34199 226063
34199 27198...

result:

ok 

Test #33:

score: 0
Accepted
time: 209ms
memory: 73620kb

input:

300000 300000
250262 108557
36440 111738
259064 66615
88605 43386
260541 275344
76928 252260
279043 236897
21247 157333
238473 161399
265756 215178
140308 71619
117500 149768
134732 17082
113291 253909
293724 74646
105559 242557
236341 218483
60849 231150
19467 211315
293231 140252
144279 152827
567...

output:

65639
20352 792
792 256571
56167 204080
204080 148417
114393 86371
86371 82485
290757 263749
263749 189943
263749 72722
144002 36498
36498 55807
55807 282538
51195 204692
204692 167374
47618 205644
205644 78427
78427 154460
175181 109012
175181 113173
119220 121875
121875 74804
121875 178062
147078 ...

result:

ok 

Test #34:

score: 0
Accepted
time: 195ms
memory: 77204kb

input:

300000 300000
15365 223849
234713 89428
44159 126180
92257 246187
20201 171260
26574 272604
129201 204920
177482 67514
208925 85239
239250 70220
132804 207081
210776 162668
152720 273073
206305 58281
132098 159530
231655 94182
284558 185502
98680 144249
235770 210288
107957 1677
58340 132660
60948 1...

output:

74478
234871 229364
229364 207172
169489 285106
285106 283957
37218 53848
53848 156081
74783 133907
133907 275599
264410 73297
73297 48497
203778 63705
63705 14106
208690 239352
208690 7557
192836 140775
192836 247357
251247 77974
77974 10391
130040 62074
62074 176630
176630 137386
205281 220918
220...

result:

ok 

Test #35:

score: 0
Accepted
time: 210ms
memory: 76252kb

input:

300000 300000
264209 237107
164191 214490
90232 89651
276245 80342
224383 64403
53614 72694
155635 199436
249591 15236
289188 15961
103491 33968
156389 81886
109351 209229
171440 267294
163870 248401
131969 178756
9221 169177
260694 220315
269088 35874
290037 297526
265364 174673
76454 106953
295403...

output:

75775
220658 178866
178866 216830
62906 21962
21962 116799
86622 244957
86622 275732
275732 282829
120836 261832
261832 121099
177873 98125
98125 245147
3193 99308
99308 6290
241828 276396
241828 172777
50796 242671
242671 253554
211594 71198
71198 172384
109726 193456
193456 184137
106811 39703
397...

result:

ok 

Test #36:

score: 0
Accepted
time: 204ms
memory: 91048kb

input:

300000 200000
268875 299698
49456 238911
253416 131715
166479 165219
69608 253468
140528 186619
137943 109067
207499 182543
136182 122354
12682 142171
251354 129349
262603 24974
127211 266575
64257 59084
15494 188941
46131 74253
201532 186289
280188 54683
67889 147936
51625 190200
14525 267957
21567...

output:

299980
145829 32823
32823 256239
256239 207157
207157 222259
222259 194249
222259 78764
78764 67338
67338 117617
67338 29039
29039 46826
46826 108696
108696 74352
74352 14672
14672 160454
160454 174101
174101 286566
286566 38204
38204 48417
48417 75784
48417 287075
287075 194272
287075 289182
289182...

result:

ok 

Test #37:

score: 0
Accepted
time: 205ms
memory: 91044kb

input:

300000 200000
252299 248542
230009 292581
35373 177788
138462 49207
203763 290355
200968 46363
70737 135501
245118 130460
83904 194104
243404 182220
215102 277127
270112 266653
165260 276783
225775 51241
38318 188811
56846 27627
11119 197017
15001 49284
135322 78011
138863 47607
63330 161879
181459 ...

output:

299981
293022 11442
11442 193962
193962 223649
223649 205662
223649 216466
223649 224206
224206 288499
224206 113415
113415 13336
13336 227978
13336 217687
217687 88782
88782 198923
198923 182893
182893 7091
182893 281536
281536 121640
121640 74791
74791 159809
159809 8016
159809 95808
159809 232732...

result:

ok 

Test #38:

score: 0
Accepted
time: 211ms
memory: 91176kb

input:

300000 200000
235723 30090
67459 222058
284627 56565
234637 233195
3326 194537
94112 73402
170827 205038
72337 78377
155819 141662
41422 46461
11555 124904
277622 41037
79117 162799
219996 294
219927 188681
208776 237898
120706 173153
84405 86988
202756 8086
226100 37717
103623 179994
147240 211491
...

output:

299986
32300 276830
276830 146801
276830 239354
276830 245238
245238 132244
132244 227662
227662 276924
227662 271085
271085 112788
112788 86300
86300 98657
98657 8692
8692 233881
233881 56778
233881 206658
206658 193403
193403 185051
193403 285559
193403 87687
87687 27552
27552 122441
27552 49114
2...

result:

ok 

Test #39:

score: 0
Accepted
time: 150ms
memory: 48640kb

input:

300000 200000
80061 292736
174946 38672
259625 53067
214782 238383
163701 219665
238162 13244
180970 225561
35241 71601
144662 73871
61172 279306
161803 89218
110247 47561
169184 196068
147035 116466
54415 275886
159883 42384
125814 129529
286519 175439
31350 293381
160291 239936
16407 223094
15577 ...

output:

10710
272530 251241
251241 77618
77618 151726
151726 206517
151726 225366
151726 217983
151726 257448
151726 218780
151726 28801
151726 48377
151726 108252
151726 270990
151726 233330
151726 232226
151726 4284
151726 71131
151726 219249
151726 53130
151726 156713
151726 279941
151726 140070
151726 1...

result:

ok 

Test #40:

score: 0
Accepted
time: 169ms
memory: 62044kb

input:

300000 200000
28785 256887
113344 221367
183895 58315
159258 121177
136839 51993
105626 856
73420 154334
295324 75251
125010 294942
262624 107727
261674 270014
205575 125939
20457 117384
43418 256876
56584 84490
189540 36042
288965 253463
208755 282657
207265 73828
180315 280009
115713 151724
108850...

output:

114367
127835 69684
69684 134749
87585 270860
270860 255185
76781 74411
74411 253975
253975 93072
253975 273815
138651 134534
138651 35271
35271 22069
35271 222753
35271 83761
124726 237236
237236 269824
269824 224551
269824 270631
270631 47743
270631 58526
175956 251647
251647 11798
81817 239273
81...

result:

ok 

Test #41:

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

input:

300000 200000
149389 218612
106968 188276
89140 206644
55452 209146
215641 195248
178521 234035
268446 174218
3256 271482
100726 58776
246041 270239
247658 175460
275470 81543
17752 221131
136286 272104
180366 163839
227459 253230
277971 291653
213804 204057
135967 165528
206844 244444
108319 191172...

output:

117343
10776 87264
87264 17727
17727 141615
27022 148279
148279 159050
51852 15643
15643 83497
191594 99735
99735 76446
62682 287522
287522 219137
219137 125526
125526 176415
291314 33005
33005 243860
243860 157841
188465 165880
188465 251354
251354 27316
66426 136352
66426 36815
36815 134309
36815 ...

result:

ok 

Test #42:

score: 0
Accepted
time: 162ms
memory: 63160kb

input:

300000 200000
74279 138727
286432 186669
275837 138414
211187 37987
262056 34763
61485 70542
294955 10724
121762 196438
65069 115877
69931 169035
12923 201472
136006 232958
144257 247816
194195 7750
74389 244628
15768 176829
220044 134051
116159 227393
135299 36882
17107 138355
242615 64967
82311 93...

output:

121169
227141 152199
152199 86191
61743 100902
100902 234920
234920 234891
269298 154656
154656 195258
178314 36854
36854 238445
36854 254481
171480 97697
97697 50479
50479 36323
27924 272580
272580 102454
102454 183948
265743 266417
266417 85195
266417 247458
42199 1303
1303 20104
1303 171572
1303 ...

result:

ok 

Extra Test:

score: 0
Extra Test Passed