QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#828456#9914. 前往何方zhenjianuo202530 455ms6700kbC++202.4kb2024-12-23 16:46:302024-12-23 16:47:16

Judging History

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

  • [2024-12-23 16:47:16]
  • 评测
  • 测评结果:30
  • 用时:455ms
  • 内存:6700kb
  • [2024-12-23 16:46:30]
  • 提交

answer

#include<bits/stdc++.h>
#include "wheretoreach.h"
using namespace std;
#define vec vector
#define pb push_back
#define eb emplace_back
#define siz(vec) ((int)(vec).size())
#define all(vec) (vec).begin(),(vec).end()
template<class T>
void operator +=(vec<T> &a,T b){a.push_back(b);}
template<class T>
void operator --(vec<T> &a){a.pop_back();}
#define pii pair<int,int>
#define x first
#define y second
#define mp make_pair
#define exc(exp) if(exp)continue;
#define stop(exp) if(exp)break;
#define ret(exp) if(exp)return;
#define deb(var) cerr<<#var<<'='<<(var)<<"; "
#define debl(var) cerr<<#var<<'='<<(var)<<";\n"
#define ins insert
#define era erase
#define lb lower_bound
#define inf (long long)(1e9)
template<class T>
bool Min(T &x,T y){return x>y?x=y,1:0;}
template<class T>
bool Max(T &x,T y){return x<y?x=y,1:0;}

int add(int x);
int remove(int x);
void report(int x,int y);

mt19937 eng(random_device{}());
int n,vis[10010],tmp[10010],ins[10010],ord[10010];
void sol(int l,int r,vec<int> w){
    ret(l>r);
    int mid=(l+r)>>1;

    vec<int> v;
    if(l==1&&r==n){
        v=w;
    }else{
        for(auto x:w)tmp[x]=0;
        fill(vis+l,vis+r+1,0);
        iota(ord+l,ord+r+1,l);
        shuffle(ord+l,ord+r+1,eng);
        for(int T=1;T<=4;T++){
            for(int j=l;j<=r;j++){
                int i=ord[j];
                exc(vis[i]);
                if(add(i)>1){
                    remove(i);
                }else{
                    ins[i]=1;
                    vis[i]=1;
                }
            }
            for(auto x:w){
                exc(tmp[x]);
                if(x<=l){
                }else if(x<=r){
                    tmp[x]=1;
                }else{
                    if(add(x)>1)tmp[x]=1;
                    assert(remove(x)<=1);
                }
            }
            for(int i=l;i<=r;i++){
                if(ins[i]){
                    remove(i);
                    ins[i]=0;
                }
            }
            if(!count(vis+l,vis+r+1,0))break;
        }
        for(auto x:w){
            if(tmp[x])v+=x;
        }
    }

    w=v;
    if(l==r){
        for(auto x:w){
            report(l,x);
        }
    }else{
        sol(l,mid,w);
        sol(mid+1,r,w);
    }
}
void solve(int N){
    n=N;
    vec<int> v(n-1);
    iota(all(v),2);
    sol(1,n,v);
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 9ms
memory: 3980kb

input:

500
310 77
468 235
218 93
58 406
223 334
159 243
204 48
144 107
492 288
447 165
102 407
340 299
450 126
140 234
209 62
111 204
453 306
4 476
126 358
183 317
360 489
149 158
232 22
326 372
92 383
410 24
199 14
401 480
69 329
192 167
409 152
426 354
435 60
146 404
334 187
208 305
123 55
30 79
469 72
2...

output:

31404
1

result:

ok Accepted. 31404 queries used.

Test #2:

score: 10
Accepted
time: 10ms
memory: 4272kb

input:

500
60 412
153 399
248 57
59 152
349 209
303 223
412 181
6 375
158 63
490 178
176 462
313 417
187 411
19 431
30 448
302 264
252 56
427 269
53 429
147 358
417 154
21 326
358 157
450 340
256 324
489 160
193 72
491 65
259 17
153 368
484 55
294 305
27 420
144 119
229 70
22 32
90 432
150 356
398 42
473 2...

output:

31730
1

result:

ok Accepted. 31730 queries used.

Test #3:

score: 10
Accepted
time: 10ms
memory: 3980kb

input:

500
434 238
470 430
111 20
414 129
408 188
220 491
483 375
203 240
315 401
344 357
315 429
246 486
291 403
465 23
477 67
155 34
27 457
349 305
220 496
384 242
87 8
74 141
458 119
206 177
246 125
332 461
111 343
413 210
280 405
288 407
60 84
70 140
31 482
110 473
94 6
361 294
96 279
438 428
295 379
1...

output:

31678
1

result:

ok Accepted. 31678 queries used.

Test #4:

score: 10
Accepted
time: 9ms
memory: 4268kb

input:

500
358 385
92 131
274 356
210 2
35 490
296 407
58 286
37 111
60 291
199 463
325 346
356 309
169 213
165 28
373 176
80 274
331 446
358 345
229 75
426 264
223 318
487 478
415 183
418 339
405 133
180 441
485 41
493 445
187 238
249 76
7 419
264 105
103 321
288 287
20 1
172 391
365 88
247 396
402 206
31...

output:

31348
1

result:

ok Accepted. 31348 queries used.

Test #5:

score: 10
Accepted
time: 8ms
memory: 4036kb

input:

500
457 191
315 191
191 459
163 191
416 191
217 191
279 191
75 191
7 191
206 191
191 317
108 191
223 191
225 191
191 414
196 191
191 248
191 264
38 191
15 191
406 191
191 480
454 191
191 212
99 191
321 191
415 191
191 240
298 191
468 191
191 187
191 340
191 19
170 191
191 430
191 496
222 191
191 386...

output:

27042
1

result:

ok Accepted. 27042 queries used.

Test #6:

score: 10
Accepted
time: 9ms
memory: 3960kb

input:

500
136 391
151 227
114 291
227 444
481 304
227 139
450 55
227 117
109 343
441 227
398 436
248 181
485 227
167 358
227 174
228 206
107 213
227 331
279 447
321 65
208 440
288 183
470 227
227 380
427 227
408 162
493 196
56 378
434 266
227 9
54 227
227 491
227 469
151 191
92 496
265 227
242 296
456 349...

output:

30520
1

result:

ok Accepted. 30520 queries used.

Test #7:

score: 10
Accepted
time: 9ms
memory: 3956kb

input:

500
32 112
430 35
282 448
388 442
25 72
281 420
9 27
245 294
28 470
119 144
343 6
4 31
236 429
230 264
285 469
463 303
365 443
169 297
374 7
345 475
420 143
388 31
403 175
51 67
288 311
86 473
349 488
239 105
402 328
9 164
150 370
205 260
439 11
62 245
115 409
272 439
319 142
466 409
407 478
89 197
...

output:

31340
1

result:

ok Accepted. 31340 queries used.

Test #8:

score: 10
Accepted
time: 9ms
memory: 3988kb

input:

500
237 221
171 286
204 484
179 375
401 385
84 107
167 463
459 69
326 325
234 72
500 138
291 498
80 204
339 383
369 240
344 335
68 327
193 7
294 389
364 102
369 69
495 187
445 386
18 6
144 25
287 205
356 347
143 49
90 74
450 386
55 477
480 11
309 227
63 332
257 23
414 431
207 151
449 19
393 118
441 ...

output:

31534
1

result:

ok Accepted. 31534 queries used.

Subtask #2:

score: 20
Accepted

Test #9:

score: 20
Accepted
time: 76ms
memory: 4428kb

input:

2500
887 818
1296 878
1605 2107
803 2410
1919 1135
860 1160
1364 2414
1375 500
894 2173
2322 2449
211 1732
1821 573
413 1556
1574 1977
709 162
2002 1577
1626 1895
1563 688
2151 2293
661 69
317 1170
2335 1549
1481 1349
1500 779
1593 735
1824 2380
639 2334
1496 2335
1956 1384
2476 1583
1035 163
720 70...

output:

208630
2

result:

ok Accepted. 208630 queries used.

Test #10:

score: 20
Accepted
time: 79ms
memory: 4440kb

input:

2500
1186 1927
2337 1044
1440 973
1563 297
1771 1852
921 834
1121 2156
679 211
1146 2132
1537 825
821 1240
1372 133
77 174
2453 1807
1357 550
1620 2020
2024 528
1666 1812
720 900
1243 2090
1665 1738
445 1306
2039 1721
1370 930
948 2331
521 121
1581 2059
1752 2039
218 785
988 2477
121 2462
578 503
11...

output:

211712
2

result:

ok Accepted. 211712 queries used.

Test #11:

score: 20
Accepted
time: 79ms
memory: 4720kb

input:

2500
778 2243
2254 352
1211 233
607 2369
1908 1499
2053 1966
1790 438
1032 703
898 2
1461 1159
1757 2022
1030 753
1123 2124
2346 528
1604 1207
341 1255
2435 999
526 888
1881 1472
251 618
1381 1303
981 1982
130 809
1623 1399
2229 1011
1836 1243
277 2147
588 1119
1980 1235
19 1795
734 2088
845 1841
89...

output:

209256
2

result:

ok Accepted. 209256 queries used.

Test #12:

score: 20
Accepted
time: 78ms
memory: 4428kb

input:

2500
1883 628
95 1337
203 1367
2078 760
115 2231
786 1486
931 248
2064 1215
336 193
175 1360
844 284
1105 102
2413 1374
2017 399
1321 947
2194 1969
2305 390
2193 1452
48 534
974 1439
2133 1727
2209 216
631 861
2279 1004
241 1797
2298 59
790 186
897 855
460 620
841 1701
1709 1541
403 95
909 1553
975 ...

output:

208474
2

result:

ok Accepted. 208474 queries used.

Test #13:

score: 20
Accepted
time: 68ms
memory: 4784kb

input:

2500
2420 40
1914 40
1373 40
817 40
985 40
40 237
40 1843
40 839
1673 40
40 1611
1631 40
40 1805
2378 40
391 40
40 1198
40 622
1232 40
40 1799
648 40
40 760
40 1163
1883 40
1033 40
2221 40
40 1020
1136 40
493 40
40 2379
404 40
40 84
2215 40
1746 40
40 2259
40 1966
1050 40
112 40
1637 40
40 196
1795 ...

output:

213604
2

result:

ok Accepted. 213604 queries used.

Test #14:

score: 20
Accepted
time: 58ms
memory: 4448kb

input:

2500
1402 1724
1724 1895
2497 667
190 1343
1690 1724
807 612
1724 2012
1581 1724
1973 1724
385 2129
474 1736
1724 1671
1724 807
1724 232
1096 447
1928 1724
1724 2404
868 579
1724 1779
1724 1167
793 1542
684 1469
874 785
58 1724
2108 1724
1724 1470
2269 2042
1724 1346
2451 8
250 1393
751 1825
2353 11...

output:

180314
2

result:

ok Accepted. 180314 queries used.

Test #15:

score: 20
Accepted
time: 73ms
memory: 4548kb

input:

2500
107 684
1016 2062
840 2253
1686 2339
2322 150
2143 535
918 623
2360 1782
1109 1519
1698 1588
1379 329
2119 1632
733 1390
557 1680
1013 2386
1767 268
2346 154
674 465
1757 549
801 1875
1090 1020
1521 2205
1861 129
2144 613
552 1341
970 855
41 1750
896 23
2106 1953
1656 1861
2408 1509
151 1301
70...

output:

209278
2

result:

ok Accepted. 209278 queries used.

Test #16:

score: 20
Accepted
time: 77ms
memory: 4496kb

input:

2500
810 880
2265 2017
1745 430
2088 1832
491 2189
1915 2457
1846 1557
118 1427
1269 980
1427 2245
590 709
2041 1179
1161 57
2069 1870
1950 2333
1378 885
385 195
1277 524
458 1603
1025 1041
646 1451
2036 903
2499 1796
823 1850
1030 957
1584 2049
67 1325
386 1257
1095 1452
1078 143
709 978
225 1771
1...

output:

209152
2

result:

ok Accepted. 209152 queries used.

Subtask #3:

score: 0
Wrong Answer

Test #17:

score: 29.2312
Acceptable Answer
time: 451ms
memory: 6000kb

input:

10000
6139 8917
131 5800
5366 5247
1298 5035
3966 3518
4889 7202
6547 1919
5829 9494
8012 6029
3868 6403
1909 8116
5734 6122
2683 4779
9275 6673
7433 9042
7646 2032
3547 6306
1943 8382
4061 6428
8240 3548
460 2795
3451 4320
5904 6627
8709 7621
8706 3534
748 4873
8101 4261
5359 3304
6254 4687
6492 53...

output:

1019220
3

result:

points 0.4175885714 1019220 queries used.

Test #18:

score: 29.3306
Acceptable Answer
time: 455ms
memory: 6232kb

input:

10000
2681 8564
3271 4429
6658 3180
2428 7273
8907 2727
5939 1929
2539 1768
7178 7722
3420 8555
1346 811
3608 2345
6181 6871
5539 8722
4731 8049
8581 7954
3979 384
9678 3503
7073 6690
240 7950
16 7004
1591 8818
5422 3777
3382 852
1805 6181
1965 2752
6507 7858
9373 4985
6912 2901
9954 4194
1029 7631
...

output:

1016734
3

result:

points 0.4190091429 1016734 queries used.

Test #19:

score: 29.4913
Acceptable Answer
time: 449ms
memory: 5936kb

input:

10000
1342 5746
3635 7521
8778 5159
4764 6368
6494 390
174 9762
1667 1808
8257 9287
8449 8308
8952 6760
4300 8776
8608 304
6035 8674
3012 2422
326 676
2883 2429
5929 6038
4183 6495
3578 6621
9215 894
6669 521
3507 7339
1972 75
9478 8427
9802 5494
2085 6339
2258 6254
9484 4048
4093 3234
4063 7612
695...

output:

1012718
3

result:

points 0.421304 1012718 queries used.

Test #20:

score: 29.6361
Acceptable Answer
time: 451ms
memory: 5908kb

input:

10000
960 6995
1934 8650
2086 4139
5869 6110
9863 5419
2434 7853
22 8305
3104 5436
956 8596
611 3208
8137 4802
2959 6835
9790 1374
16 1928
3933 905
8563 7148
5395 4769
7120 9867
6938 958
902 1635
8282 6853
5974 8667
1135 3544
7781 3724
4634 7479
4471 1938
7625 6909
9912 8309
479 976
9773 4057
5726 1...

output:

1009098
3

result:

points 0.4233725714 1009098 queries used.

Test #21:

score: 33.3932
Acceptable Answer
time: 391ms
memory: 5976kb

input:

10000
2047 2226
2047 7482
2047 8002
2047 7874
2471 2047
3951 2047
2047 5793
255 2047
2047 6651
2047 5389
2047 5158
2047 8377
2047 5620
2047 5128
4171 2047
2047 8760
2551 2047
2047 4395
6197 2047
2047 1146
2047 6031
306 2047
9529 2047
2923 2047
2047 8946
590 2047
7820 2047
1096 2047
2047 974
7717 204...

output:

949102
3

result:

points 0.4770457143 949102 queries used.

Test #22:

score: 44.9811
Acceptable Answer
time: 314ms
memory: 5868kb

input:

10000
9237 9177
5414 5467
9237 68
8026 5985
1926 8283
9237 5640
2996 9237
9237 7417
697 5166
4466 9237
9237 3310
2971 9237
5521 4979
2643 5677
9756 6100
9237 2937
2632 3463
9237 6803
1859 9237
4701 7368
9237 7173
1651 9237
4732 9237
9237 1166
9237 1435
3515 1302
9237 4921
5777 484
8256 7830
9237 960...

output:

775284
3

result:

points 0.6425866667 775284 queries used.

Test #23:

score: 29.3277
Acceptable Answer
time: 414ms
memory: 6700kb

input:

10000
3351 7696
386 4051
2241 9958
5285 4525
7161 2908
7124 4675
7578 3532
6592 6812
2280 4890
5171 2148
1771 6993
1718 1169
1531 842
1069 3468
1241 7188
5705 5652
4914 677
2363 2546
8117 3848
5023 4984
3187 715
9328 8777
6053 8764
8107 9235
9653 762
3797 183
1973 7599
6175 426
4656 599
6049 1826
84...

output:

1016808
3

result:

points 0.4189668571 1016808 queries used.

Test #24:

score: 29.8916
Acceptable Answer
time: 435ms
memory: 6444kb

input:

10000
5331 5033
284 7891
7368 9841
362 6335
1612 1970
1891 4399
7757 7074
9288 3477
7448 9763
3509 1445
6735 2012
789 5030
580 772
8908 720
5536 9474
7121 9522
400 7117
9891 3408
5189 3478
8321 7282
128 8852
3641 4280
7366 5284
3677 1034
43 5886
3769 6199
840 7421
7820 7433
8385 7144
6847 6525
7776 ...

output:

1002710
3

result:

points 0.4270228571 1002710 queries used.

Test #25:

score: 0
Wrong Answer
time: 444ms
memory: 5972kb

input:

10000
7095 4156
8385 4062
1344 1135
4986 3337
7854 7371
2851 9326
1519 5574
6022 842
5234 5680
3231 6393
8582 6669
9168 404
9598 4201
2790 4058
1129 1470
540 5692
7671 8007
1822 1877
921 2656
3941 8775
1467 8859
6488 2326
3813 1878
703 3013
1872 8016
6217 7984
6859 9824
4065 8161
3345 7351
9343 9598...

output:

-1
3

result:

wrong answer Wrong Answer (or #queries exceeded).