QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#849795#7980. 区间切割KiharaTouma#100 ✓2324ms56596kbC++144.6kb2025-01-09 18:18:432025-01-09 18:18:45

Judging History

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

  • [2025-01-09 18:18:45]
  • 评测
  • 测评结果:100
  • 用时:2324ms
  • 内存:56596kb
  • [2025-01-09 18:18:43]
  • 提交

answer

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

const int N = 1e5 + 10, M = 1e6 + 10;
int n, m, id, L[N], R[N];
vector<pair<int, int> > ad[N], dl[N];

//加入删除 (time, pos)
//1.区间查询 time >= T,pos\in[l,r] 的最小 time
//2.区间查询 time <= T,pos\in[L,l) 的最大 pos
//3.区间查询 time <= T,pos\in(r,R] 的最小 pos
//a[pos] = time [l,r]内 <=T 的最大/最小下标;[l,r]内最小值

pair<int, int> t[M*4];
void build(int p, int l, int r){
    // for(int i = 1; i <= m; ++ i){
    //     t[i] = make_pair(m + 1, 0);
    // }
    t[p] = make_pair(m + 1, l);
    if(l != r){
        int mid = l + r >> 1;
        build(p<<1, l, mid);
        build(p<<1|1, mid+1, r);
    }
}
void add(int p, int l, int r, int x, int v){
    // t[x] = make_pair(v, x);
    if(l == r){
        t[p] = make_pair(v, x);
    } else {
        int mid = l + r >> 1;
        if(x <= mid){
            add(p<<1, l, mid, x, v);
        } else {
            add(p<<1|1, mid+1, r, x, v);
        }
        t[p] = min(t[p<<1], t[p<<1|1]);
    }
}
pair<int, int> qmn(int p, int l, int r, int ql, int qr){
    if(qr < l || r < ql){
        return make_pair(m+1, 0);
    } else if(ql <= l && r <= qr){
        return t[p];
    } else {
        int mid = l + r >> 1;
        return min(qmn(p<<1, l, mid, ql, qr), qmn(p<<1|1, mid+1, r, ql, qr));
    }
    // pair<int, int> mn = make_pair(m + 1, 0);
    // for(int i = ql; i <= qr; ++ i) mn = min(mn, t[i]);
    // return mn;
}
int qmxpos(int p, int l, int r, int ql, int qr, int tt){
    // printf("%d %d %d %d %d %d %d\n", p, l, r, ql, qr, tt, t[p].first);
    if(qr < l || r < ql || t[p].first > tt){
        return 0;
    } else if(l == r){
        // puts("ok");
        return l;
    } else {
        int mid = l + r >> 1;
        int tmp = qmxpos(p<<1|1, mid+1, r, ql, qr, tt);
        if(tmp != 0){
            return tmp;
        } else {
            return qmxpos(p<<1, l, mid, ql, qr, tt);
        }
    }
    // int rs = 0;
    // for(int i = ql; i <= qr; ++ i){
    //     if(t[i].first <= tt) rs = max(rs, i);
    // }
    // return rs;
}
int qmnpos(int p, int l, int r, int ql, int qr, int tt){
    if(qr < l || r < ql || t[p].first > tt){
        return m + 1;
    } else if(l == r){
        // puts("ok");
        return l;
    } else {
        int mid = l + r >> 1;
        int tmp = qmnpos(p<<1, l, mid, ql, qr, tt);
        if(tmp != m + 1){
            return tmp;
        } else {
            return qmnpos(p<<1|1, mid+1, r, ql, qr, tt);
        }
    }
    // int rs = m + 1;
    // for(int i = ql; i <= qr; ++ i){
    //     if(t[i].first <= tt) rs = min(rs, i);
    // }
    // return rs;
}

int main(){
    scanf("%d%d%d", &n, &m, &id);
    for(int i = 1; i <= n; ++ i){
        scanf("%d%d", &L[i], &R[i]);
    }
    for(int i = 1; i <= m; ++ i){
        int x, l, r;
        scanf("%d%d%d", &x, &l, &r);
        // if(l <= 2&&r >= 2){
        ad[l].push_back(make_pair(i, x));
        dl[r].push_back(make_pair(i, x));
        // if(L[2] <= x && x <= R[2]){
        // printf("%d %d %d ", x, l, r);
        //     if(x-L[2] >= R[2] - x) R[2] = x; else L[2] = x;
        //     printf("%d %d\n", L[2], R[2]);
        // }
        // }
    }
    // printf("[%d %d]", L[2], R[2]);
    // puts("----");
    build(1, 1, m);
    for(int i = 1; i <= n; ++ i){
        for(auto j : ad[i]){
            // printf("add %d %d\n", j.first, j.second);
            add(1, 1, m, j.second, j.first);
        }
        int l = L[i], r = R[i], tim = 0;
        while(tim <= m && r - l + 1 > 2){
            int len = (r - l + 1) / 3;
            int le = l + len, ri = r - len;
            pair<int, int> tt = qmn(1, 1, m, le, ri);
            if(tt.first == m + 1){
                break;
            }
            int pos = tt.second;
            tim = tt.first;
            int nle = max(l, qmxpos(1, 1, m, l, le-1, tim));
            int nri = min(r, qmnpos(1, 1, m, ri+1, r, tim));
            if(pos - nle >= nri - pos){
                tie(l, r) = tie(nle, pos);
            } else {
                tie(l, r) = tie(pos, nri);
            }
        }
        int len = (r - l + 1) / 3;
        int le = l + len, ri = r - len;
        int nle = max(l, qmxpos(1, 1, m, l, le-1, m));
        int nri = min(r, qmnpos(1, 1, m, ri+1, r, m));
        tie(l, r) = tie(nle, nri);
        // printf("%d\n", qmxpos(1, 1, m, l, le-1, 0));
        printf("%d %d\n", l, r);
        for(auto j : dl[i]){
            // printf("add %d %d\n", j.second, m+1);
            add(1, 1, m, j.second, m + 1);
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 7ms
memory: 10384kb

input:

4740 4996 1
7 14
7 13
13 14
1 2
1 18
9 16
13 17
2 7
12 14
9 15
3 4
7 11
19 23
21 24
23 25
22 24
19 22
19 24
20 21
19 25
20 25
21 24
19 21
19 20
19 22
20 24
29 39
32 35
27 40
25 42
28 32
27 33
41 42
31 34
29 39
30 39
39 43
25 45
34 35
25 39
29 37
34 35
48 49
45 50
45 50
46 50
45 46
48 50
46 47
45 49
...

output:

7 14
7 13
13 14
1 2
10 16
10 16
13 16
5 7
12 13
10 12
3 4
7 11
19 23
21 23
23 25
22 23
19 22
19 23
20 21
19 22
23 25
22 23
19 21
19 20
19 22
21 24
29 39
32 35
35 38
38 40
28 31
27 31
41 42
31 32
36 38
36 38
39 41
37 41
34 35
33 36
30 37
34 35
48 49
45 47
45 48
46 48
45 46
48 49
46 47
46 48
49 51
46 ...

result:

ok 4740 lines

Test #2:

score: 5
Accepted
time: 9ms
memory: 9508kb

input:

5000 5000 1
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1 5000
1...

output:

2 5000
2 5000
3 5000
3 5000
3 4997
6 4997
7 4996
7 4996
7 4996
7 4995
8 4995
8 4995
8 4993
9 4993
9 4993
9 4993
9 4992
9 4991
10 4991
10 4991
10 4991
11 4991
11 4991
11 4991
11 4990
11 4989
11 4988
11 4988
12 4988
12 4988
14 4987
14 4987
15 4986
17 4986
18 4986
18 4986
19 4986
19 4986
20 4984
20 498...

result:

ok 5000 lines

Test #3:

score: 5
Accepted
time: 10ms
memory: 9120kb

input:

4996 5000 1
2557 4014
1858 2442
2 4142
848 1370
1869 4138
832 1475
130 1372
3518 4544
575 3419
1594 3880
49 2699
755 3110
182 1588
525 1112
3968 4878
676 780
94 2434
626 2167
1656 3242
1498 1728
3192 4829
1003 3511
2148 3482
568 4689
2893 2962
936 1609
541 4264
2632 3019
2858 4955
918 1144
3758 4730...

output:

2557 4014
1858 2442
2453 3388
848 1048
2453 3388
1295 1475
130 449
3888 4508
1432 2453
2647 3345
57 449
1432 2453
678 1048
678 1048
4266 4392
678 780
226 449
678 1048
1656 2453
1498 1728
3939 4167
1432 2453
2647 3142
2647 3142
2893 2962
936 1048
678 1048
2827 2996
2996 3142
918 1048
3942 4167
1755 2...

result:

ok 4996 lines

Test #4:

score: 5
Accepted
time: 17ms
memory: 9540kb

input:

4999 4998 1
857 3443
192 1036
869 1382
2450 2717
942 4095
635 4678
1754 4905
380 4966
431 1685
3953 4754
3576 4706
3131 4989
1359 3670
3411 4260
393 2857
22 383
1538 2682
452 4403
2043 2818
2165 2301
3162 4523
1066 2269
184 1779
3401 4997
1433 1858
1158 3006
2383 4467
79 2746
5 35
1621 1767
817 1841...

output:

857 3443
392 1036
1040 1382
2450 2717
1647 4095
2556 3756
2556 3756
2556 3756
1040 1640
4044 4137
3576 3756
3131 3756
2556 3068
3411 3756
2556 2857
22 383
2371 2556
2643 3068
2371 2556
2165 2262
3171 3526
2140 2262
1647 1779
3526 3756
1647 1780
2371 2556
2383 2556
2371 2556
5 35
1647 1767
1647 1780
...

result:

ok 4999 lines

Test #5:

score: 5
Accepted
time: 15ms
memory: 9556kb

input:

4998 4999 1
1 1682
852 2449
1446 4128
238 2230
333 1197
1894 2304
1654 4892
2022 4832
891 2487
4629 4683
2714 2811
1487 2710
2542 4104
3958 4660
1398 3018
3203 4052
1199 2714
2586 4314
2664 2890
2815 4553
2947 3261
3762 3828
52 2284
539 3072
843 2842
1634 4849
3791 4084
1461 3503
173 1475
2553 3821
...

output:

1189 1350
1629 1766
2661 2715
457 531
469 510
2240 2273
2986 2998
2986 2998
1412 1430
4654 4668
2783 2798
2472 2488
3397 3406
4561 4583
2477 2485
3360 3373
2477 2485
3337 3347
2846 2870
3637 3645
3103 3114
3773 3778
630 640
1033 1048
1285 1288
3114 3122
4040 4045
3114 3122
1285 1288
3114 3122
3114 3...

result:

ok 4998 lines

Test #6:

score: 5
Accepted
time: 20ms
memory: 10364kb

input:

4992 5000 1
1535 1813
153 2333
99 3559
2727 4799
549 3906
58 1434
3397 4711
1509 2673
1078 4450
811 2963
2041 4885
1816 2052
4429 4781
1475 1692
2451 3289
3509 4324
1854 3905
744 1952
1956 3815
2178 3466
32 2816
590 2399
390 579
581 1418
1335 2720
2576 3417
856 4484
112 3192
1363 1981
3791 4204
1448...

output:

1579 1710
2206 2272
2206 2272
3329 3358
2707 2761
1424 1434
3419 3449
2179 2195
2765 2778
2765 2778
2765 2778
2045 2050
4429 4437
1687 1692
3283 3289
3509 3523
2765 2778
1944 1951
2415 2421
2415 2421
2195 2201
2195 2201
574 579
1410 1415
2195 2201
3333 3338
2195 2201
2195 2201
1976 1979
3794 3799
21...

result:

ok 4992 lines

Test #7:

score: 5
Accepted
time: 20ms
memory: 8984kb

input:

4500 5000 1
4031 4531
1548 2048
2819 3319
410 910
535 1035
2683 3183
3966 4466
3617 4117
2628 3128
2339 2839
733 1233
432 932
2995 3495
3669 4169
1185 1685
1229 1729
2930 3430
2261 2761
1040 1540
111 611
3746 4246
4367 4867
1067 1567
1103 1603
1092 1592
2646 3146
4172 4672
3181 3681
773 1273
1295 17...

output:

4313 4444
1819 2013
3259 3319
890 910
1025 1034
3163 3175
4450 4463
4067 4096
3120 3125
2828 2834
1220 1228
918 932
3482 3492
3989 3996
1677 1685
1719 1727
3424 3429
2753 2758
1532 1537
605 608
3999 4001
4862 4865
1565 1567
1599 1601
1584 1588
2999 3001
4669 4671
3676 3679
1265 1269
1791 1794
1405 1...

result:

ok 4500 lines

Subtask #2:

score: 15
Accepted

Test #8:

score: 15
Accepted
time: 150ms
memory: 17884kb

input:

15986 190089 2
42 49
30 175
48 51
118 143
158 177
116 188
41 58
14 36
88 162
21 152
112 129
67 170
208 217
208 214
206 215
217 225
229 232
226 242
206 216
222 233
213 220
228 239
231 237
227 239
217 235
214 229
326 373
293 304
354 371
320 337
298 348
278 280
335 344
271 341
298 379
340 355
323 324
3...

output:

45 46
148 149
49 50
124 125
173 174
148 149
45 46
20 21
148 149
115 116
115 116
148 149
211 212
209 210
206 207
217 218
229 230
236 237
206 207
229 230
217 218
236 237
235 236
236 237
229 230
217 218
360 361
300 301
360 361
330 331
316 317
278 279
336 337
316 317
316 317
349 350
323 324
315 316
316 ...

result:

ok 15986 lines

Test #9:

score: 15
Accepted
time: 215ms
memory: 17892kb

input:

15999 200000 2
11192 176034
21186 188716
34083 91582
9276 161890
46059 186144
11688 54159
74436 167207
41199 122588
9608 38383
34892 149808
134871 151267
10171 161414
188681 191587
172318 198100
126159 180725
55389 170314
151376 193226
173811 177024
47876 198944
146986 149477
1894 8576
21617 67515
2...

output:

92387 92388
92387 92388
81204 81205
92387 92388
92387 92388
43701 43702
120363 120364
92387 92388
12415 12416
92387 92388
142244 142245
92387 92388
189842 189843
192230 192231
163690 163691
92387 92388
163690 163691
175524 175525
92387 92388
148727 148728
3453 3454
43701 43702
43701 43702
92387 9238...

result:

ok 15999 lines

Test #10:

score: 15
Accepted
time: 194ms
memory: 18224kb

input:

16000 199991 2
30 199922
75 199955
8 199935
98 199945
112 199961
11 199928
10 199938
53 199960
115 199918
44 199928
90 199922
109 199952
58 199960
48 199897
29 199924
11 199894
115 199868
29 199884
27 199940
76 199922
4 199934
100 199933
36 199933
34 199939
40 199929
11 199983
79 199904
40 199934
14...

output:

127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822 127823
127822...

result:

ok 16000 lines

Test #11:

score: 15
Accepted
time: 210ms
memory: 15936kb

input:

16000 200000 2
150810 170810
75119 95119
111375 131375
137907 157907
9999 29999
158906 178906
138237 158237
53779 73779
48818 68818
141757 161757
143924 163924
68607 88607
112376 132376
37884 57884
157355 177355
97185 117185
136147 156147
79354 99354
139282 159282
113410 133410
14366 34366
118778 13...

output:

158381 158382
94092 94093
127496 127497
140913 140914
14831 14832
161656 161657
140913 140914
72291 72292
52973 52974
158381 158382
158381 158382
82666 82667
127496 127497
52973 52974
158381 158382
106904 106905
140913 140914
94092 94093
140913 140914
127496 127497
27875 27876
127496 127497
52973 52...

result:

ok 16000 lines

Subtask #3:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #12:

score: 15
Accepted
time: 835ms
memory: 53612kb

input:

99993 966043 3
2 77
6 71
27 41
32 75
7 42
4 47
46 54
20 44
3 84
33 86
43 83
2 53
104 236
110 161
249 253
203 235
144 234
164 224
123 221
192 226
93 243
155 208
207 224
285 286
309 315
260 348
283 326
282 293
305 319
259 325
286 332
262 338
270 342
272 300
303 312
279 344
269 339
290 311
324 345
428 ...

output:

53 67
33 48
33 40
58 63
13 20
13 17
52 54
36 39
59 61
47 59
43 70
15 34
176 206
124 127
250 253
223 230
227 230
183 186
163 169
208 214
219 223
162 172
208 224
285 286
309 315
287 296
287 299
289 293
308 309
275 279
302 306
302 306
335 338
275 281
303 306
287 294
287 294
300 308
324 330
428 430
398 ...

result:

ok 99993 lines

Test #13:

score: 15
Accepted
time: 1662ms
memory: 54816kb

input:

100000 1000000 3
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1...

output:

601832 701728
601832 636356
601832 636356
601832 636356
601832 636356
601832 636356
604767 636356
604767 621060
604767 621060
604767 621060
604767 621060
604767 621060
604767 612660
604767 612660
604767 612660
604767 612660
604767 612660
604767 612660
604767 612660
604767 612660
604767 612660
604767...

result:

ok 100000 lines

Test #14:

score: 15
Accepted
time: 2012ms
memory: 56596kb

input:

100000 1000000 3
50428 395631
251099 423800
569598 902869
118561 578842
262971 623776
221006 897703
336674 410600
337560 950635
451350 837689
482854 801402
166775 535863
311333 541451
97702 234031
699303 912286
301076 730897
274758 332293
1476 154471
566349 900591
730803 838040
284169 486318
185176 ...

output:

249660 344833
283268 319883
661518 678788
505555 542075
402410 447338
738948 778046
356814 369809
832071 849884
514051 534925
515066 534925
469693 482918
479363 482918
155030 161535
747313 758707
515066 528095
285774 295345
100481 120842
747313 758707
747313 758707
455820 461768
285774 295345
979557...

result:

ok 100000 lines

Test #15:

score: 15
Accepted
time: 1414ms
memory: 46884kb

input:

100000 1000000 3
201 999793
275 999898
156 999960
203 999801
40 999817
45 999900
236 999874
68 999933
271 999766
206 999986
37 999845
286 999943
238 999988
1 999945
68 999762
77 999913
104 999976
39 999899
178 999999
253 999863
239 999974
117 999686
115 999777
274 999805
255 999954
218 999765
87 999...

output:

662497 663469
653775 654712
733442 733885
372680 372890
486155 486320
486155 486320
486155 486320
486155 486320
486155 486320
484638 484718
547990 548071
547990 548071
547306 547372
542584 542634
558121 558153
558121 558153
558121 558153
559259 559335
558121 558153
558087 558121
369661 369728
394575...

result:

ok 100000 lines

Subtask #4:

score: 15
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 15
Accepted
time: 232ms
memory: 18392kb

input:

15999 200000 4
94576 142857
854 176013
158956 197420
29343 171559
2984 144564
2977 42993
99064 131711
32946 174497
52770 187816
3443 172847
6481 25166
22023 69036
8508 106080
18844 57677
63031 102892
7573 94329
18348 79392
13507 16832
5889 195211
7077 142636
71732 199589
8727 36892
537 146269
174881...

output:

100046 100047
100046 100047
158956 158957
100046 100047
100046 100047
42991 42992
100046 100047
100046 100047
100046 100047
100046 100047
25164 25165
69034 69035
100046 100047
57675 57676
100046 100047
94327 94328
79390 79391
16830 16831
100046 100047
100046 100047
100046 100047
36890 36891
100046 1...

result:

ok 15999 lines

Test #17:

score: 15
Accepted
time: 138ms
memory: 17716kb

input:

16000 199991 4
53321 56599
153197 179602
112936 149973
69840 169363
98309 126002
47615 197087
57265 120572
28206 186928
19469 188010
15694 28436
108291 130771
6015 6518
28058 83919
19261 85101
3983 108884
20615 55176
80966 149023
99371 167319
75750 126761
16830 169616
6415 99196
24508 74628
26264 16...

output:

55705 55706
165076 165077
133827 133828
115078 115079
115078 115079
115078 115079
90079 90080
115078 115079
115078 115079
21332 21333
115078 115079
6391 6392
65080 65081
65080 65081
65080 65081
40081 40082
115078 115079
115078 115079
115078 115079
65080 65081
65080 65081
40081 40082
65080 65081
8382...

result:

ok 16000 lines

Test #18:

score: 15
Accepted
time: 197ms
memory: 18184kb

input:

15998 199994 4
13247 189626
72786 180273
90459 116882
10324 33307
81336 129369
50892 192316
50833 180520
54287 101534
89855 169438
152041 162095
21174 82365
96685 100491
123704 178372
4282 5827
39243 161587
31421 65360
10258 159955
90562 156481
5350 164249
5583 21037
46935 116741
69527 198954
58536 ...

output:

93330 93331
93330 93331
93330 93331
33305 33306
93330 93331
93330 93331
93330 93331
93330 93331
133329 133330
152041 152042
81476 81477
100489 100490
133329 133330
5825 5826
93330 93331
65358 65359
93330 93331
133329 133330
93330 93331
21035 21036
93330 93331
93330 93331
93330 93331
93330 93331
9333...

result:

ok 15998 lines

Test #19:

score: 15
Accepted
time: 118ms
memory: 15996kb

input:

15997 200000 4
51 199904
120 199932
118 199997
83 199901
68 199889
93 199993
115 199948
72 199996
5 199902
111 199949
2 199886
108 199878
3 199898
14 199894
88 199911
70 199943
32 199944
34 199933
42 199900
3 199914
78 199887
111 200000
4 199886
79 199961
61 199905
57 199951
31 199935
85 199975
122 ...

output:

100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329 100330
100329...

result:

ok 15997 lines

Test #20:

score: 15
Accepted
time: 215ms
memory: 17988kb

input:

16000 200000 4
68574 88574
105589 125589
18480 38480
129987 149987
66561 86561
50204 70204
115995 135995
83303 103303
40139 60139
18128 38128
83820 103820
162987 182987
79376 99376
14905 34905
12078 32078
43527 63527
132440 152440
26620 46620
117865 137865
11264 31264
97757 117757
157751 177751
1609...

output:

79999 80000
119999 120000
38478 38479
139999 140000
79999 80000
70202 70203
135993 135994
99999 100000
59999 60000
38126 38127
99999 100000
179999 180000
99374 99375
34903 34904
32076 32077
59999 60000
152438 152439
39999 40000
137863 137864
31262 31263
117755 117756
177749 177750
36091 36092
191169...

result:

ok 16000 lines

Subtask #5:

score: 10
Accepted

Dependency #4:

100%
Accepted

Test #21:

score: 10
Accepted
time: 976ms
memory: 42400kb

input:

99996 947121 5
9 12
1 17
7 15
10 16
12 17
2 6
12 19
10 15
92 179
69 173
86 103
23 126
38 170
22 161
40 175
109 128
39 177
71 208
91 131
106 133
124 212
95 158
119 192
190 198
227 231
242 247
238 264
276 283
220 283
250 288
300 303
303 308
293 318
295 309
290 306
299 308
295 316
292 314
314 316
301 3...

output:

10 11
13 14
10 11
10 11
13 14
4 5
13 14
10 11
129 130
129 130
88 89
113 114
129 130
129 130
129 130
113 114
129 130
129 130
113 114
113 114
179 180
129 130
129 130
193 194
228 229
242 243
254 255
276 277
260 261
260 261
301 302
305 306
299 300
299 300
299 300
302 303
299 300
299 300
314 315
302 303
...

result:

ok 99996 lines

Test #22:

score: 10
Accepted
time: 1501ms
memory: 43344kb

input:

100000 1000000 5
494346 897303
107868 113437
272324 456781
37165 563726
326117 819795
422146 648146
59233 837125
451160 936322
410686 567240
734864 872650
135886 980193
724722 819410
110030 806256
25977 309624
706106 725427
445441 880074
21131 625313
624908 672027
306782 903362
246473 433750
724131 ...

output:

706959 706960
112189 112190
381190 381191
381190 381191
381190 381191
465711 465712
381190 381191
706959 706960
419764 419765
778364 778365
381190 381191
778364 778365
381190 381191
193283 193284
717756 717757
706959 706960
381190 381191
634955 634956
381190 381191
381190 381191
778364 778365
38169 ...

result:

ok 100000 lines

Test #23:

score: 10
Accepted
time: 1578ms
memory: 43384kb

input:

100000 1000000 5
790 223616
459909 597583
584788 717446
592806 786070
402308 508221
508543 919166
559962 582794
23627 836036
246243 994788
334989 906745
461032 682520
353198 590626
269371 469929
846413 870668
229282 924732
777943 828631
309029 744876
571265 646715
42265 707617
541702 897038
524433 9...

output:

223614 223615
500494 500495
584788 584789
592806 592807
500494 500495
508543 508544
559962 559963
500494 500495
500494 500495
500494 500495
500494 500495
500494 500495
469927 469928
846413 846414
500494 500495
777943 777944
500494 500495
571265 571266
500494 500495
541702 541703
524433 524434
237208...

result:

ok 100000 lines

Test #24:

score: 10
Accepted
time: 1039ms
memory: 41420kb

input:

100000 1000000 5
13218 116871
214284 996712
483064 533333
485783 665243
423726 972039
416646 590874
613759 975796
543970 651519
50629 340955
741753 980909
182243 681703
257139 494393
852434 996254
244615 747572
358331 938862
610899 926922
690091 810492
794342 891145
27042 413436
761827 997716
691772...

output:

77101 77102
514601 514602
514601 514602
514601 514602
514601 514602
514601 514602
764601 764602
577101 577102
139601 139602
764601 764602
264601 264602
389601 389602
889601 889602
264601 264602
514601 514602
764601 764602
764601 764602
827101 827102
139601 139602
889601 889602
764601 764602
264601 2...

result:

ok 100000 lines

Test #25:

score: 10
Accepted
time: 1671ms
memory: 43500kb

input:

100000 1000000 5
93807 609997
362345 815688
657653 965922
10381 935033
7402 684011
152507 601641
106898 191929
145327 158114
4638 249337
392465 444344
767464 847358
251657 409684
331823 978997
55026 264500
675312 749663
600621 853703
431228 863873
330257 965270
148560 203397
148338 414288
7394 30780...

output:

466666 466667
466666 466667
666666 666667
466666 466667
466666 466667
466666 466667
191927 191928
158112 158113
249335 249336
440327 440328
767464 767465
407405 407406
466666 466667
264498 264499
675312 675313
666666 666667
466666 466667
466666 466667
203395 203396
407405 407406
307804 307805
238042...

result:

ok 100000 lines

Test #26:

score: 10
Accepted
time: 863ms
memory: 41516kb

input:

100000 1000000 5
179 999746
158 999895
234 999706
183 999908
298 999993
28 999843
114 999710
203 999819
193 999964
276 999876
43 999775
109 999882
23 999804
115 999999
248 999699
67 999863
91 999685
153 999685
255 999747
280 999878
38 999727
113 999775
186 999743
55 999988
173 999898
261 999835
274 ...

output:

500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466 500467
500466...

result:

ok 100000 lines

Test #27:

score: 10
Accepted
time: 1813ms
memory: 43484kb

input:

100000 1000000 5
391788 491788
670131 770131
313875 413875
26820 126820
494010 594010
302166 402166
455364 555364
715248 815248
153936 253936
685809 785809
187614 287614
594 100594
75861 175861
639252 739252
540144 640144
3600 103600
823545 923545
735903 835903
867285 967285
690561 790561
821160 921...

output:

491786 491787
770129 770130
399999 400000
99999 100000
594008 594009
399999 400000
555362 555363
799999 800000
253934 253935
785807 785808
287612 287613
99999 100000
175859 175860
699999 700000
599999 600000
99999 100000
899999 900000
799999 800000
967283 967284
790559 790560
899999 900000
279818 27...

result:

ok 100000 lines

Subtask #6:

score: 20
Accepted

Dependency #1:

100%
Accepted

Dependency #4:

100%
Accepted

Test #28:

score: 20
Accepted
time: 132ms
memory: 20140kb

input:

15990 187039 6
59 69
73 80
76 78
73 75
75 79
79 80
75 82
76 78
139 246
83 249
147 306
259 296
329 355
315 336
349 363
312 336
328 342
313 336
313 328
320 377
313 340
327 356
338 351
314 345
350 359
307 325
394 459
382 431
391 415
574 588
545 560
656 727
640 671
655 697
657 707
635 707
605 625
606 68...

output:

60 61
73 77
76 77
73 74
76 79
79 80
75 82
76 78
218 227
137 138
187 191
276 283
337 344
330 336
351 363
330 335
337 340
320 325
316 320
345 349
316 320
345 349
342 351
314 322
356 359
308 322
396 405
408 410
410 412
578 580
552 554
689 716
666 669
670 678
697 704
672 679
614 620
663 665
633 636
659 ...

result:

ok 15990 lines

Test #29:

score: 20
Accepted
time: 152ms
memory: 19996kb

input:

16000 200000 6
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 200000
1 2000...

output:

4 199995
8 199989
14 199980
23 199977
27 199971
33 199968
38 199961
43 199957
48 199951
53 199945
56 199937
61 199930
67 199926
71 199920
78 199918
86 199915
95 199911
101 199905
106 199901
113 199897
119 199893
127 199887
130 199873
133 199868
137 199857
142 199850
150 199843
158 199837
164 199834
...

result:

ok 16000 lines

Test #30:

score: 20
Accepted
time: 256ms
memory: 21476kb

input:

16000 200000 6
63340 101036
61699 191788
9904 70523
101686 136557
91763 177434
183940 192372
48736 53281
37888 101629
65802 167277
112510 148614
136302 151413
113342 199268
63178 177092
3026 11420
10686 28792
5775 184912
78899 178252
141455 158155
14995 69795
27480 68911
28020 51634
43739 66182
3111...

output:

89056 101036
150636 155002
55267 62723
113423 118032
130865 137364
187113 190972
50628 51992
59219 62723
139744 141551
121191 124084
139744 141551
184549 185525
108939 110355
6226 8369
24940 25701
40971 41970
108939 110355
142869 144606
40971 41970
40971 41970
40971 41970
59712 61161
37213 38203
107...

result:

ok 16000 lines

Test #31:

score: 20
Accepted
time: 346ms
memory: 19016kb

input:

16000 200000 6
126425 136886
104686 196308
96317 193991
49704 174110
106578 179415
9645 105013
20298 126615
150292 172624
41076 89826
44727 99633
17698 188160
61708 87887
51310 134027
18537 67436
90485 113514
49603 77577
56482 159359
127271 188117
43172 59783
102091 182459
109460 122525
50935 57952
...

output:

131121 136886
110660 119760
98779 101674
99677 101674
107540 109295
99677 101674
99677 101674
150566 152538
86555 88767
98971 99633
99677 101674
86555 87583
99677 101674
64834 67436
99677 101674
77244 77548
99677 101674
127624 128060
59386 59783
102091 104024
109656 109989
57768 57952
72072 72485
99...

result:

ok 16000 lines

Test #32:

score: 20
Accepted
time: 190ms
memory: 17608kb

input:

16000 200000 6
132518 195711
121648 131066
47613 69283
92443 93490
30700 97819
30022 40659
128578 163731
49481 125583
41271 142868
40478 82546
10349 191614
1223 161060
11444 189216
10047 91881
126715 187902
24185 130380
38503 42207
53603 183655
2911 138882
170243 197332
89189 161036
119534 127839
13...

output:

180240 180356
125562 126102
63217 63376
92764 92909
95950 96032
36741 36774
150561 150611
108952 108980
108952 108980
80465 80480
108902 108932
70889 70899
70889 70899
70889 70899
171173 171186
121197 121224
40054 40069
121176 121197
121176 121197
195740 195756
121176 121197
121176 121197
158707 158...

result:

ok 16000 lines

Test #33:

score: 20
Accepted
time: 243ms
memory: 17464kb

input:

16000 200000 6
13033 56717
45059 159205
27955 61703
26217 53494
134240 179096
74567 149342
101885 147823
34905 164692
6596 77500
28677 184382
96367 114440
57129 195987
1212 167311
125285 167899
173864 194737
35378 188657
179487 186317
27767 138781
22835 84500
31643 76150
112966 172880
65677 154818
1...

output:

56603 56711
133173 133299
61524 61620
53402 53477
134240 134276
93268 93337
133248 133299
93298 93337
77464 77494
93298 93326
111056 111094
93298 93326
93302 93326
133248 133299
173865 173878
93313 93326
179491 179498
93313 93326
84480 84492
76097 76126
133248 133299
92868 92872
133248 133299
85826 ...

result:

ok 16000 lines

Test #34:

score: 20
Accepted
time: 164ms
memory: 20076kb

input:

16000 200000 6
93 199876
32 199923
40 199958
126 199996
6 199883
71 199978
109 199898
122 199917
69 199920
73 199947
67 199891
122 199903
29 199896
113 200000
104 199899
17 199952
85 199966
38 199949
43 199876
63 199895
73 199956
122 199880
86 199878
124 199955
38 199911
108 199992
54 199999
41 1999...

output:

99646 99798
99705 99798
99705 99798
99736 99798
99736 99798
99736 99798
99798 99843
99770 99798
99770 99798
99770 99798
99770 99796
99770 99796
99770 99796
99770 99796
99771 99796
99771 99788
99771 99788
99771 99785
99771 99785
99771 99785
99771 99785
99771 99785
99771 99785
99771 99785
99771 99785
...

result:

ok 16000 lines

Test #35:

score: 20
Accepted
time: 264ms
memory: 17360kb

input:

16000 200000 6
127875 147875
35695 55695
139766 159766
63855 83855
54516 74516
98857 118857
138666 158666
116798 136798
157322 177322
11517 31517
146685 166685
91817 111817
124949 144949
98879 118879
16126 36126
99220 119220
175252 195252
145167 165167
90332 110332
107855 127855
10527 30527
6369 263...

output:

147617 147875
55661 55695
159514 159698
83737 83805
74370 74459
118792 118836
158633 158650
136740 136782
177304 177322
31476 31501
166656 166682
111785 111802
144924 144949
118871 118879
36097 36126
119164 119203
195230 195252
165121 165149
110328 110331
119988 120001
30516 30527
26314 26344
41511 ...

result:

ok 16000 lines

Subtask #7:

score: 20
Accepted

Dependency #3:

100%
Accepted

Dependency #5:

100%
Accepted

Dependency #6:

100%
Accepted

Test #36:

score: 20
Accepted
time: 1121ms
memory: 53180kb

input:

100000 1000000 7
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1000000
1 1...

output:

4 999994
13 999989
17 999986
24 999982
28 999977
32 999976
35 999971
39 999967
46 999962
53 999957
56 999954
61 999953
65 999952
66 999948
68 999947
76 999945
83 999942
85 999939
89 999933
94 999931
97 999929
105 999924
109 999921
114 999918
117 999914
123 999909
127 999905
131 999899
141 999895
148...

result:

ok 100000 lines

Test #37:

score: 20
Accepted
time: 2285ms
memory: 56544kb

input:

100000 1000000 7
119024 579895
872517 943739
648609 674400
464382 540755
238908 869955
106125 449994
710591 988252
752503 985733
199824 430836
779651 830314
796418 862008
50977 68388
212655 901097
37253 392958
126752 830098
659033 831530
313854 813339
68544 988706
231648 300425
548069 846480
59592 1...

output:

501180 569852
872517 907085
648609 674400
501180 516091
501180 516091
421379 438473
726755 753968
753968 773875
426021 430836
786622 804059
796418 804059
50977 62650
493408 500839
378842 386700
493408 500645
660748 665278
493408 499813
493408 499813
284926 292740
553916 560827
99473 103256
493408 49...

result:

ok 100000 lines

Test #38:

score: 20
Accepted
time: 1375ms
memory: 49136kb

input:

100000 1000000 7
749622 922523
256638 692739
551192 807796
573611 910855
403786 918640
707563 998570
116398 310873
428033 674205
413886 760325
26500 614584
454776 623627
317552 572242
826048 867349
35399 656650
732056 958324
8688 686721
312018 427066
911894 937627
373789 906611
834226 932427
27090 7...

output:

880153 880735
639080 639629
702942 703081
886593 886931
886593 886798
894820 895070
253830 253964
612000 612122
610249 610316
603389 603493
603389 603493
547182 547279
847091 847130
603417 603493
846902 846951
518177 518212
355866 355920
921852 921902
733843 733872
915246 915281
508265 508351
733329...

result:

ok 100000 lines

Test #39:

score: 20
Accepted
time: 1920ms
memory: 46664kb

input:

100000 1000000 7
579897 695951
110993 671958
15252 355436
9825 594938
74879 833832
653513 997464
833788 904567
205895 523660
70847 565380
141983 748289
714802 875772
298772 652796
24342 604146
224085 851466
332354 907678
82466 489404
389995 485379
82515 548529
716265 735442
124 809842
327578 791386
...

output:

666025 667273
666066 666473
355297 355436
505798 506173
505798 506057
666608 666758
833788 833842
466498 466553
466504 466553
466504 466553
714892 715004
466504 466553
466504 466553
466504 466553
466504 466553
466504 466553
466504 466553
466504 466553
716277 716299
466504 466553
466504 466543
466504...

result:

ok 100000 lines

Test #40:

score: 20
Accepted
time: 1163ms
memory: 47164kb

input:

100000 1000000 7
311 999888
232 999892
50 999996
100 999886
239 999951
87 999704
142 999840
262 999885
272 999848
291 999973
155 999906
166 999755
301 999740
193 999990
56 999965
67 999942
84 999757
3 999787
47 999846
92 999733
270 999935
284 999702
293 999995
134 999869
170 999789
206 999763
140 99...

output:

500991 502921
500353 500511
500353 500470
500353 500434
500353 500434
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442 500470
500442...

result:

ok 100000 lines

Test #41:

score: 20
Accepted
time: 2324ms
memory: 49148kb

input:

100000 1000000 7
79065 179065
616122 716122
71856 171856
516897 616897
199044 299044
536157 636157
96138 196138
439740 539740
565002 665002
791523 891523
273321 373321
436293 536293
854838 954838
451395 551395
578115 678115
554454 654454
565947 665947
858708 958708
438723 538723
307485 407485
629640...

output:

178435 179065
715694 716122
171305 171619
616673 616789
298941 299001
636090 636157
196083 196128
539585 539668
664951 665002
891489 891523
373302 373321
536227 536278
954784 954829
551377 551391
678087 678101
654423 654454
665913 665931
958663 958706
538697 538717
407465 407480
729567 729608
345982...

result:

ok 100000 lines