QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#208234#6260. Historic Exhibitionlmq26052003AC ✓8ms7184kbC++203.6kb2023-10-09 11:18:412023-10-09 11:18:41

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3880kb

input:

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

output:

1
4
3

result:

ok correct

Test #2:

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

input:

2 2
1 1
2 3
1 1

output:

impossible

result:

ok impossible

Test #3:

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

input:

2 3
9 8
4 5
4 9 5

output:

impossible

result:

ok impossible

Test #4:

score: 0
Accepted
time: 2ms
memory: 4560kb

input:

1000 1000
141 140
239 240
380 380
114 115
345 345
60 60
341 340
224 223
400 399
125 124
163 162
53 53
62 62
326 326
36 36
91 92
187 186
48 49
123 123
232 233
275 274
374 373
321 322
251 250
347 348
221 222
64 65
143 144
65 65
135 136
209 208
336 336
118 117
189 190
87 86
58 58
66 67
185 185
289 288
...

output:

854
944
757
456
727
724
955
561
607
787
288
377
876
636
533
963
642
898
792
985
715
967
421
904
662
936
591
730
781
710
875
768
909
765
762
657
728
990
326
938
918
614
961
333
494
986
289
646
941
864
426
748
445
802
903
991
493
722
753
491
729
667
832
315
859
809
422
953
910
988
588
544
676
352
536
...

result:

ok correct

Test #5:

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

input:

100 100
9 9
3 3
9 9
5 4
8 7
19 20
8 8
10 11
19 18
18 18
8 9
20 20
15 14
8 9
16 15
8 7
8 9
7 8
7 8
2 3
5 6
12 13
8 7
14 13
13 13
8 9
3 2
16 15
17 18
15 14
18 19
6 6
14 14
4 3
17 18
16 16
4 3
9 10
3 2
8 8
12 11
4 5
8 8
5 4
5 6
6 5
14 13
9 10
1 2
12 12
19 18
19 18
12 13
11 12
1 1
9 8
8 8
4 3
1 2
3 4
7 ...

output:

72
80
95
57
43
93
65
99
91
52
47
100
59
86
96
40
29
88
55
94
77
66
33
26
79
51
85
49
63
13
97
74
89
71
92
58
75
82
42
98
73
84
56
87
76
62
37
78
60
35
90
64
68
9
69
39
83
23
38
34
17
4
53
48
30
54
46
50
41
61
14
27
12
32
31
16
21
28
25
11
10
7
81
70
5
20
67
24
3
2
19
6
8
18
36
22
15
45
1
44

result:

ok correct

Test #6:

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

input:

100 60
11 11
43 44
15 16
27 27
18 18
8 8
2 1
58 57
23 22
10 11
14 15
9 8
37 38
57 56
32 33
48 49
23 22
13 12
6 5
28 29
4 4
4 3
6 7
14 15
6 7
42 42
5 5
2 2
48 48
2 1
18 17
49 48
15 16
8 7
38 38
35 34
33 32
38 39
36 35
41 40
18 19
7 7
45 44
53 52
11 11
26 25
15 14
35 36
5 4
7 8
56 55
19 18
52 52
35 35...

output:

40
6
89
70
41
78
47
12
29
50
2
16
8
48
25
35
65
22
30
23
24
33
15
66
28
39
18
60
26
59
36
4
3
55
13
31
77
14
7
63
53
1
43
20
100
5
10
11
32
9
42
19
46
34
96
51
17
38
64
44

result:

ok correct

Test #7:

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

input:

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

output:

7
2
4
9
3
1
5

result:

ok correct

Test #8:

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

input:

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

output:

4
1
2

result:

ok correct

Test #9:

score: 0
Accepted
time: 8ms
memory: 7156kb

input:

10000 10000
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
...

output:

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
9941...

result:

ok correct

Test #10:

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

input:

10000 10000
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
10 11
...

output:

impossible

result:

ok impossible

Test #11:

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

input:

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

output:

impossible

result:

ok impossible

Test #12:

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

input:

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

output:

4
2
3
1

result:

ok correct

Test #13:

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

input:

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

output:

impossible

result:

ok impossible

Test #14:

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

input:

0 0


output:


result:

ok correct

Test #15:

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

input:

1 0
1 1


output:


result:

ok correct

Test #16:

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

input:

0 1
1

output:

impossible

result:

ok impossible

Test #17:

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

input:

2 0
1 2
2 1


output:


result:

ok correct

Test #18:

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

input:

1 1
2 2
1

output:

impossible

result:

ok impossible

Test #19:

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

input:

12 10
1 2
1 2
2 3
2 3
2 3
2 3
3 3
3 3
3 4
4 5
8 9
8 9
1 1 3 3 3 3 3 3 3 4

output:

2
1
9
8
7
6
5
4
3
10

result:

ok correct

Test #20:

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

input:

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

output:

4
2
1

result:

ok correct

Test #21:

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

input:

3 2
1 1
1 1
1 1
1 1

output:

2
1

result:

ok correct

Test #22:

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

input:

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

output:

1
3
2
5
4
7
6
8

result:

ok correct

Test #23:

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

input:

10 5
1824 1825
411 410
4507 4508
4012 4013
3657 3658
3813 3812
9196 9195
3612 3612
107 106
5575 5575
1825 410 4507 4013 3658

output:

1
2
3
4
5

result:

ok correct

Test #24:

score: 0
Accepted
time: 5ms
memory: 7184kb

input:

7907 7305
1614 1614
1911 1912
7213 7213
5742 5742
1445 1446
913 914
5419 5419
8198 8197
4726 4726
1495 1496
908 909
9658 9658
6650 6649
8026 8025
7172 7172
7549 7550
5784 5785
9924 9925
3150 3149
204 204
6536 6537
2009 2008
5111 5112
9724 9723
4407 4407
9448 9448
504 504
2035 2036
808 808
6533 6534
...

output:

impossible

result:

ok impossible

Test #25:

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

input:

5849 2078
1 2
9 10
5 4
4 3
6 6
2 2
10 9
7 6
1 2
7 7
6 7
3 3
5 6
3 2
6 5
4 4
10 9
4 4
5 6
9 9
8 9
8 8
8 9
1 1
5 6
5 6
6 7
3 3
3 3
7 8
1 1
1 1
10 9
9 8
10 10
2 2
5 5
3 4
5 5
10 10
6 5
8 9
8 9
5 4
10 9
5 4
7 8
4 5
3 3
1 1
4 3
10 10
1 2
2 1
8 9
10 10
8 9
8 8
6 5
5 5
5 6
4 4
8 8
3 3
3 3
9 10
9 10
8 8
3 4...

output:

2068
1971
1968
2149
2148
2111
1967
2092
1982
2109
2139
1965
2062
1897
1964
2090
2106
2129
2077
2058
2053
2033
2030
2017
1985
2100
1953
2016
2071
2065
1938
2123
2102
2018
1935
1973
1949
2098
2137
2091
2015
2095
2012
2014
1893
1921
2130
2084
2088
2056
2081
2069
2048
2002
1948
2079
1915
2067
2004
2078
...

result:

ok correct

Test #26:

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

input:

6860 65
4385 4384
6177 6177
2840 2841
9943 9943
7434 7434
3062 3062
6494 6495
2996 2997
398 398
3079 3078
9199 9198
6932 6931
5376 5376
1247 1247
6853 6854
8779 8780
3534 3533
2548 2547
5477 5477
7404 7404
1603 1603
8023 8023
1990 1991
1776 1776
9769 9768
8250 8250
6182 6181
6496 6497
1046 1045
3839...

output:

impossible

result:

ok impossible

Test #27:

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

input:

2307 1314
7 6
7 7
3 4
6 5
1 1
6 7
4 5
5 4
4 3
8 8
8 7
9 10
9 8
2 1
7 6
9 9
2 3
7 6
6 6
6 6
7 7
6 5
8 9
3 3
7 7
10 10
4 3
9 9
2 3
9 10
3 3
5 4
6 7
4 4
1 1
4 4
2 1
1 2
7 8
9 10
5 5
9 9
8 7
1 2
8 8
1 2
4 4
9 8
3 2
9 8
10 10
4 3
5 5
9 8
6 6
6 7
7 7
3 4
3 2
7 8
10 10
3 4
8 8
4 3
8 7
1 2
2 3
10 9
6 7
1 2
...

output:

1104
1210
1371
1297
1295
1476
1399
1110
1279
1353
1228
1277
1294
1192
1095
1084
1338
1364
1087
1086
1080
1340
1083
1475
1325
1454
1291
1183
1081
1172
1224
1316
1335
1452
1071
1334
1222
1332
1323
1270
1067
1315
1182
1266
1079
1354
1309
1258
1305
1312
1257
1062
1352
1177
1259
1156
1440
1304
1254
1170
...

result:

ok correct

Test #28:

score: 0
Accepted
time: 5ms
memory: 5852kb

input:

7314 4728
6 7
10 9
5 6
6 7
10 10
1 2
8 9
7 7
5 6
1 2
3 2
2 2
3 3
6 6
6 5
7 6
5 5
7 6
9 10
4 5
9 8
9 9
10 9
7 7
9 10
1 2
8 7
3 4
1 2
5 5
3 3
8 8
6 5
3 3
1 2
1 1
2 3
9 10
7 8
2 1
10 9
6 5
9 8
7 8
8 8
7 7
1 2
3 2
7 6
9 10
4 3
5 6
9 10
8 7
1 2
10 9
10 9
3 4
1 2
5 6
4 5
8 7
8 7
3 4
3 4
8 7
3 2
1 1
8 7
4 ...

output:

4672
4744
4590
4703
4919
4666
4595
4802
4663
4687
4614
4660
4586
4796
4789
4585
4763
4794
4573
4788
4915
4562
4604
4780
4762
4907
4899
4742
4757
4882
4776
4880
4640
4775
4547
4574
4600
4878
4753
4635
4773
4592
4634
4750
4544
4770
4318
4584
4626
4534
4530
4860
4736
4767
4583
4579
4578
4852
4572
4301
...

result:

ok correct

Test #29:

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

input:

9031 3313
1 1
8 7
2 2
1 1
1 1
7 7
10 10
4 5
3 3
4 5
2 1
6 6
2 1
7 7
5 6
6 6
2 2
5 5
5 5
5 4
7 7
8 8
2 3
7 7
9 9
1 2
4 3
1 2
7 6
5 4
2 2
7 7
2 3
8 8
5 4
4 5
5 6
8 9
6 6
4 3
2 1
7 7
2 1
4 4
1 1
2 3
4 4
5 6
3 2
1 2
6 7
3 2
8 9
9 8
8 8
3 4
7 7
8 8
3 2
5 5
2 3
1 2
4 4
6 7
9 9
4 3
4 4
6 7
2 2
2 1
4 5
10 1...

output:

2809
3432
3431
3245
3617
2807
3401
3436
3427
3604
3170
2970
3595
2936
3592
3584
3421
3420
3430
2929
3399
3235
2805
2800
3403
3398
3224
2965
3414
2914
3413
3576
3378
3168
2960
3561
3366
2912
3166
3152
2944
3393
3388
3222
3150
3411
2797
2796
2907
3362
3377
3216
2934
3350
3549
3538
3345
2927
3407
3368
...

result:

ok correct

Test #30:

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

input:

4282 507
5 5
7 6
4 3
7 8
1 1
2 1
10 10
10 10
7 6
3 2
6 7
7 8
1 1
4 4
6 5
10 10
5 4
3 4
9 8
3 3
6 5
1 1
6 7
2 2
10 10
5 5
6 7
4 5
9 9
1 2
8 7
3 3
6 7
3 2
1 1
5 4
7 8
4 4
6 5
6 6
7 7
10 10
1 1
7 8
8 9
3 3
3 4
6 7
3 3
10 9
6 6
2 2
2 2
2 1
10 10
2 2
3 4
10 9
10 9
4 5
3 4
4 5
2 3
7 8
2 2
2 1
5 4
2 1
3 2
...

output:

508
459
532
527
550
448
545
482
472
435
414
534
480
533
541
467
486
506
471
536
442
523
510
529
481
424
502
495
469
405
452
409
522
465
369
512
519
437
444
433
430
466
499
487
392
492
419
428
427
483
517
463
401
387
441
484
461
470
422
434
477
464
363
460
511
455
426
454
415
379
509
406
413
402
476
...

result:

ok correct

Test #31:

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

input:

5976 8723
5 6
10 10
7 7
5 6
9 8
7 8
10 10
9 10
3 4
3 4
7 6
2 2
7 8
9 8
4 5
10 9
10 10
9 9
7 6
4 5
4 3
9 9
9 9
7 8
3 2
8 9
4 5
7 8
7 8
6 5
5 4
2 2
10 10
5 6
5 6
3 4
1 1
7 8
3 2
6 5
8 7
5 5
7 8
3 2
2 3
1 2
2 3
6 7
9 10
2 3
6 6
8 8
2 1
1 2
3 4
8 7
10 9
1 1
5 5
2 2
3 3
4 5
3 4
9 8
1 2
8 8
5 6
3 3
5 4
8 ...

output:

impossible

result:

ok impossible

Test #32:

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

input:

7389 5821
1 2
6 5
10 9
9 10
10 9
3 3
8 8
1 1
3 4
8 7
1 2
9 8
4 4
10 9
10 9
9 10
5 4
10 10
6 7
9 10
8 9
2 3
7 6
7 7
10 9
3 2
10 10
7 6
6 6
2 2
6 6
3 2
9 8
4 3
3 4
4 5
10 10
8 8
1 2
2 2
4 5
7 8
1 1
6 7
9 9
9 9
10 9
3 2
2 1
5 6
10 10
10 10
6 7
6 6
6 5
1 1
3 4
1 1
8 9
1 1
2 1
3 2
7 7
5 5
7 7
6 7
7 6
4 4...

output:

5226
5879
5386
6274
5857
5788
5664
5865
5384
6268
5864
5862
5781
5520
5847
6266
5823
5801
5778
5662
5793
5370
5224
5777
5658
5774
5213
5513
5790
5845
5837
5457
5760
5750
5205
5451
5430
5746
5784
5200
5744
5657
5500
5852
5850
5833
5499
5825
5650
5849
6264
5775
5483
5824
5734
5423
5367
6249
5754
5832
...

result:

ok correct

Test #33:

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

input:

3326 8220
3 2
8 9
1 2
4 4
1 2
4 5
6 5
3 4
3 4
10 10
8 9
8 7
3 4
3 3
6 7
1 2
3 3
8 9
1 2
1 2
10 9
7 7
8 7
4 3
1 1
2 3
6 7
10 9
7 7
7 7
10 9
1 1
2 2
4 5
8 7
8 7
8 9
10 9
2 1
6 6
5 6
8 7
2 1
10 9
3 4
7 7
4 4
4 3
10 9
1 2
2 1
10 9
2 1
6 5
6 6
2 1
2 2
5 5
6 7
1 1
10 10
9 8
5 6
7 7
9 9
5 5
2 2
4 5
4 5
5 6...

output:

impossible

result:

ok impossible

Test #34:

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

input:

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

output:

4
2
1

result:

ok correct

Test #35:

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

input:

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

output:

2
1
3
4
5
7
6

result:

ok correct

Test #36:

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

input:

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

output:

impossible

result:

ok impossible

Test #37:

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

input:

3 3
3 4
5 6
8 9
6 7 8

output:

impossible

result:

ok impossible

Test #38:

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

input:

1 1
1 2
3

output:

impossible

result:

ok impossible

Test #39:

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

input:

3 3
100 101
101 101
101 102
101 101 101

output:

3
2
1

result:

ok correct