QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#541998#8943. Challenge Matrix Multiplicationucup-team296#AC ✓1774ms183292kbC++142.7kb2024-08-31 21:55:422024-08-31 21:55:42

Judging History

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

  • [2024-08-31 21:55:42]
  • 评测
  • 测评结果:AC
  • 用时:1774ms
  • 内存:183292kb
  • [2024-08-31 21:55:42]
  • 提交

answer

#include <bits/stdc++.h>

#define long long long int
#define DEBUG
using namespace std;

// @author: pashka

int mod = 998244353;

struct mint {
    int value = 0;

    constexpr mint() : value() {}

    mint(const long &x) {
        value = normalize(x);
    }

    static long normalize(const long &x) {
        long v = x % mod;
        if (v < 0) v += mod;
        return v;
    }

    bool operator==(const mint &x) { return value == x.value; };

    mint operator+(const mint &x) { return value + x.value; };

    mint operator-(const mint &x) { return value - x.value; };

    mint operator*(const mint &x) { return (long) value * x.value; };

    void operator+=(const mint &x) { value = normalize(value + x.value); };

    void operator-=(const mint &x) { value = normalize(value - x.value); };
};

mint power(mint a, long b) {
    mint res = 1;
    while (b > 0) {
        if (b & 1) {
            res = res * a;
        }
        a = a * a;
        b >>= 1;
    }
    return res;
}

mint inv(mint a) {
    return power(a, mod - 2);
}

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        g[x].push_back(y);
    }
    vector<vector<pair<int, int>>> pos(n);
    vector<vector<int>> p;
    auto gg = g;
    for (int i = 0; i < n; i++) {
        while (!gg[i].empty()) {
            int x = i;
            p.push_back({x});
            int t = p.size() - 1;
            pos[x].push_back({t, 0});
            while (!gg[x].empty()) {
                int y = gg[x].back();
                gg[x].pop_back();
                x = y;
                pos[x].push_back({t, p.back().size()});
                p.back().push_back(x);
            }
        }
    }
    int k = p.size();
    vector<vector<mint>> ps(k);
    for (int i = 0; i < k; i++) {
        int t = p[i].size();
        ps[i].resize(t + 1);
        for (int j = t - 1; j >= 0; j--) {
            int x = p[i][j];
            ps[i][j] = ps[i][j + 1] + inv(pos[x].size());
        }
    }

    vector<mint> res(n);

    for (int i = 0; i < k; i++) {
        vector<int> d(n);
        for (int x = n - 1; x >= 0; x--) {
            d[x] = p[i].size();
            for (auto [a, b]: pos[x]) {
                if (a == i) d[x] = b;
            }
            for (auto y: g[x]) {
                d[x] = min(d[x], d[y]);
            }
            res[x] += ps[i][d[x]];
        }
    }

    for (int i = 0; i < n; i++) {
        if (res[i] == 0) res[i] = 1;
        cout << res[i].value << "\n";
    }

    return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

4
3
1
1

result:

ok 4 number(s): "4 3 1 1"

Test #2:

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

input:

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

output:

4
3
2
1
1

result:

ok 5 number(s): "4 3 2 1 1"

Test #3:

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

input:

100 900
89 90
34 35
45 46
97 98
41 42
59 61
19 20
25 29
2 3
28 29
54 55
77 78
69 74
60 61
43 44
13 14
92 93
65 66
68 69
72 73
78 81
54 56
55 60
14 15
9 10
92 93
10 11
18 19
16 17
97 98
76 77
39 40
71 72
7 8
63 64
7 8
16 24
13 24
83 84
90 91
1 4
4 5
96 97
81 82
91 92
80 81
66 67
19 20
3 4
9 10
47 48
...

output:

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

result:

ok 100 numbers

Test #4:

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

input:

100 900
71 72
22 26
21 22
15 22
97 98
43 44
64 65
87 88
79 81
90 93
54 55
96 97
64 67
64 88
24 25
71 72
47 48
49 51
72 75
12 14
66 67
6 7
90 91
14 15
73 74
99 100
66 73
84 85
34 35
94 95
88 89
16 17
17 20
56 57
13 14
13 14
48 51
80 81
7 9
26 27
42 44
86 87
31 36
82 83
54 55
7 8
20 21
41 42
17 18
91 ...

output:

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

result:

ok 100 numbers

Test #5:

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

input:

100 916
93 97
2 3
77 78
47 50
23 24
25 31
31 32
59 61
69 74
8 9
4 5
30 31
73 74
3 4
12 15
36 37
80 84
44 47
84 85
9 18
78 79
74 76
45 46
89 96
76 78
20 21
22 24
35 36
20 22
36 37
25 26
82 83
40 42
95 96
29 30
92 93
93 94
21 22
34 35
65 66
32 33
71 72
9 11
87 88
69 71
12 13
46 47
3 4
3 4
59 62
64 65
...

output:

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

result:

ok 100 numbers

Test #6:

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

input:

100 843
62 64
78 80
10 11
31 37
37 48
64 66
24 25
77 79
68 69
10 11
76 78
89 90
37 41
20 21
42 43
30 36
47 48
66 68
10 11
18 21
59 62
30 31
42 49
56 66
78 83
37 39
65 67
96 97
24 73
26 28
21 22
82 83
94 96
39 40
8 10
89 90
51 52
92 93
85 87
34 62
6 7
97 98
13 14
5 6
29 30
7 10
41 42
70 71
21 23
48 5...

output:

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

result:

ok 100 numbers

Test #7:

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

input:

100 910
74 75
90 91
66 67
84 85
56 57
86 87
29 30
92 93
30 53
91 92
55 58
43 44
58 59
65 66
75 76
46 47
50 51
99 100
57 58
37 39
75 77
35 36
2 3
39 41
70 71
85 86
4 5
56 57
28 29
67 69
98 99
3 4
80 81
9 12
9 10
79 80
68 70
3 4
72 73
81 82
54 55
97 98
7 8
94 97
69 70
56 57
69 71
6 7
49 50
26 27
80 81...

output:

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

result:

ok 100 numbers

Test #8:

score: 0
Accepted
time: 599ms
memory: 70620kb

input:

300000 1000000
291518 291525
162078 162095
107433 107434
117028 117029
252973 252975
34296 34301
17712 17713
168224 168227
5479 5480
96730 96733
18177 18182
170140 170142
114143 114145
290862 290865
239489 239490
132218 132219
143908 143914
118103 118105
76237 76240
265590 265591
42005 42010
95874 9...

output:

296803
296802
296801
296800
296799
296797
296796
296796
296795
1
296794
296793
296792
296791
296790
296789
296788
296787
296786
296785
296784
296782
296782
296781
296780
296779
296778
296777
296776
296775
296774
296773
296772
296769
296770
296768
296768
296767
296766
296765
296764
296763
296762
2967...

result:

ok 300000 numbers

Test #9:

score: 0
Accepted
time: 934ms
memory: 70400kb

input:

300000 1000000
187606 187608
36565 36566
128950 128958
172669 172683
41451 41458
138127 138132
22729 22733
13633 13640
158041 158044
74504 74505
190220 190247
97877 97879
277477 277483
35531 35584
77716 77731
142348 142349
231107 231110
232636 232640
211702 211714
257036 257048
124062 124078
289660 ...

output:

291171
291174
291182
291188
291184
291166
291172
291157
1
291156
291183
291171
291181
291130
291178
291174
291173
291171
291155
291170
291165
291154
291150
291170
291169
291162
291164
291156
291164
291162
291160
291155
291157
291154
291156
291136
291155
291137
291149
291149
291153
291149
291145
2911...

result:

ok 300000 numbers

Test #10:

score: 0
Accepted
time: 845ms
memory: 70224kb

input:

300000 1000000
127190 127320
86211 86214
154425 154446
21608 21646
295649 295653
49413 49419
274753 274755
272272 272286
248246 248258
167611 167613
99630 99631
118018 118023
233539 233541
76885 76896
272148 272174
115623 115633
250825 250830
142266 142340
291868 291898
54308 54309
159123 159124
261...

output:

291386
291384
291383
291385
291378
291381
291366
291378
291380
291379
291378
291367
291376
291375
291365
291370
291373
291372
291369
291371
291366
291368
291364
291366
291363
291345
291363
291360
291357
291355
291351
291345
291355
291354
291353
291348
291350
291348
291345
291343
291348
291347
291345...

result:

ok 300000 numbers

Test #11:

score: 0
Accepted
time: 317ms
memory: 62068kb

input:

300000 622182
178651 178654
168896 168899
51002 51003
52671 52672
260458 260461
288275 288282
97920 97921
48060 48061
21907 21908
271103 271104
262840 262842
192846 192847
109062 109063
20122 20123
230639 230640
45404 45408
10054 10055
133116 133117
114713 114714
26310 26311
141682 141684
111622 111...

output:

299999
299998
299997
299996
299995
299994
299993
299992
299991
299990
299989
299988
299987
299986
299985
299984
299983
299982
299981
299980
299979
299978
299977
299976
299975
299974
299973
299972
299971
299970
299969
299968
299967
299966
299965
299964
299963
299962
299961
299960
299959
299958
299957...

result:

ok 300000 numbers

Test #12:

score: 0
Accepted
time: 801ms
memory: 119768kb

input:

700000 1000000
238263 238265
271765 271767
535443 535465
91436 91438
44996 45004
491072 491073
182658 182667
204466 204475
425640 425642
490507 490517
654032 654033
695412 695416
573184 573188
178765 178767
550768 550776
191441 191444
422916 422924
200846 200863
686525 686526
23786 23805
432819 4328...

output:

556560
1
556556
556558
556521
556557
556531
1
556556
556555
556555
1
556554
556553
556536
556552
556551
556549
556548
1
556541
556536
556540
556535
556537
556535
1
556536
556535
556531
556530
556241
556534
556530
556520
1
556529
556527
556530
556529
556513
556504
556525
556508
556526
1
556524
556496...

result:

ok 700000 numbers

Test #13:

score: 0
Accepted
time: 1367ms
memory: 118656kb

input:

700001 1000000
306352 306425
265123 265158
497711 497717
155684 155790
407614 407617
2099 2259
425834 425842
518856 518924
236978 236981
443915 443961
374152 374389
197908 197911
417118 417128
504272 504442
538611 538618
88243 88266
443775 443788
177312 177318
187300 187375
97432 97435
296402 296410...

output:

538889
1
538877
1
538869
538884
1
1
538877
538884
538851
538873
1
538883
538839
538876
538867
538714
1
1
538871
538850
538848
538845
1
1
538874
538848
538846
538866
538824
538868
538871
538810
538869
538787
538713
1
538867
538844
538825
538845
538845
538868
538826
538866
538866
538865
538844
538841
...

result:

ok 700001 numbers

Test #14:

score: 0
Accepted
time: 1408ms
memory: 118692kb

input:

700001 1000000
589017 589042
590183 590194
552179 552193
577163 577185
5113 5129
515920 515923
63347 63349
552589 552591
694996 695011
556536 556716
228821 228823
10040 10068
615065 615080
381081 381154
160649 160677
269486 269797
667012 667041
59793 59811
187067 187095
611138 611146
549273 549277
3...

output:

538204
538252
538262
538261
538235
538105
538104
1
538261
538260
538185
538249
538050
538196
538238
538189
538190
538180
538238
538220
538114
538188
538233
538187
538191
1
538232
538221
538179
538220
538237
538215
538184
1
1
538013
538153
538211
538193
538207
538174
538220
538219
538198
538176
53820...

result:

ok 700001 numbers

Test #15:

score: 0
Accepted
time: 1178ms
memory: 118712kb

input:

700000 1000000
120040 120043
263318 263322
22898 22912
466234 466235
513410 513421
38408 38414
570568 570571
109994 109995
176710 176727
139257 139264
170772 170781
678637 678645
224587 224593
60721 60726
586667 586677
14214 14224
330172 330196
599744 599745
81126 81189
273040 273056
511669 511677
5...

output:

1
540166
540123
540173
540168
540164
540167
540131
1
540132
540139
1
540162
1
540161
1
540141
540162
1
1
540074
540161
540160
1
540159
540135
540134
540148
540131
540147
1
1
540115
1
1
540146
540127
540138
1
540131
540137
1
540130
1
540126
540049
540123
540123
540128
540104
540125
540122
540048
5401...

result:

ok 700000 numbers

Test #16:

score: 0
Accepted
time: 886ms
memory: 119000kb

input:

700000 1000000
578333 578337
482970 482971
632615 632616
274899 274902
121483 121486
485898 485903
425408 425410
15506 15514
264010 264014
163025 163029
29696 29708
510561 510573
376805 376848
379761 379778
133594 133601
531948 531962
327842 327846
398006 398020
317404 317408
295029 295038
457342 45...

output:

545970
545963
1
545954
1
545962
545958
545962
545957
545949
545961
1
545948
1
1
545961
545961
545960
545956
545954
545955
1
545960
1
1
1
545919
1
545953
1
545947
545946
545945
545932
1
545934
545921
545936
545947
545933
545932
545942
545941
545926
545931
545936
1
545936
1
1
545920
545935
545932
5458...

result:

ok 700000 numbers

Test #17:

score: 0
Accepted
time: 404ms
memory: 128816kb

input:

700000 699998
243102 243103
86877 86878
618685 618686
212104 212105
441355 441356
470247 470248
540407 540408
27727 27728
50635 50636
66825 66826
399558 399559
277400 277401
389887 389888
30764 30765
454928 454929
376639 376640
619550 619551
449154 449155
56046 56047
47092 47093
492584 492585
342756...

output:

699999
699998
699997
699996
699995
699994
699993
699992
699991
699990
699989
699988
699987
699986
699985
699984
699983
699982
699981
699980
699979
699978
699977
699976
699975
699974
699973
699972
699971
699970
699969
699968
699967
699966
699965
699964
699963
699962
699961
699960
699959
699958
699957...

result:

ok 700000 numbers

Test #18:

score: 0
Accepted
time: 945ms
memory: 152456kb

input:

1000000 1000000
855434 855439
742537 742538
875464 875468
313713 313721
499109 499113
53966 53996
386316 386327
670014 670024
756822 756889
160756 160761
849007 849035
766125 766142
789030 789056
280721 280790
316643 316648
738437 738519
345352 345353
416793 416845
277161 277171
367258 367267
374694...

output:

660512
660505
660480
1
660510
660509
1
660508
660479
660508
660486
660485
660507
660504
660487
660488
1
1
660484
660487
660486
660447
660485
1
660470
1
1
660483
660487
660483
660480
1
1
660469
660479
660482
660481
660482
660480
660472
660475
660479
660478
1
660477
1
660473
660478
660475
660468
66047...

result:

ok 1000000 numbers

Test #19:

score: 0
Accepted
time: 1673ms
memory: 150624kb

input:

1000000 1000000
767191 767296
411052 411058
518939 518941
493475 493488
874578 874627
807369 807402
976382 976517
61774 61922
762004 762012
781188 781259
354101 354154
266537 266545
704921 704939
541522 541526
869380 869385
632577 632582
197669 197766
115346 115499
643783 643802
110485 110496
370421...

output:

638285
638150
638252
1
638262
1
638294
1
638284
638147
1
1
638269
1
1
1
1
638261
638239
1
638267
638251
638243
638261
1
638208
638246
1
1
638197
638202
638245
637954
638247
1
638251
638200
1
638245
638251
638268
1
638231
1
638238
1
638132
1
638244
1
638199
638244
638066
638243
1
1
1
1
638243
1
1
1
6...

result:

ok 1000000 numbers

Test #20:

score: 0
Accepted
time: 1774ms
memory: 150424kb

input:

1000000 1000000
368239 368287
235701 235811
449486 449489
763983 764020
294162 294183
900590 900600
335228 335400
241925 241982
165565 165585
210598 210740
992132 992136
138334 138376
742200 742261
407852 407935
572967 573022
779577 779624
641112 642260
142163 142188
610184 610202
735634 735643
8517...

output:

637172
637189
1
637184
637201
637170
637169
637200
637168
637172
1
637181
1
1
637196
1
637167
637148
637171
637185
1
1
637055
637196
637180
637190
1
1
637162
637179
1
637146
1
637187
637144
1
637156
637183
637147
1
636700
1
1
637161
1
637174
637154
637162
1
637178
637140
637160
1
1
637176
637113
1
1...

result:

ok 1000000 numbers

Test #21:

score: 0
Accepted
time: 1455ms
memory: 150732kb

input:

1000000 1000000
958691 958731
224623 224633
507702 507760
181747 181785
848190 848202
420905 420939
642870 642871
621801 621812
988528 988543
942226 942277
526176 526178
561566 561588
352214 352222
46395 46417
787559 787561
447678 447821
224044 224072
385772 385779
685720 685737
796154 796160
355933...

output:

640411
640410
1
640404
640403
640364
640393
1
640395
640362
1
1
640394
1
640324
640393
640349
1
640392
640366
640373
640361
1
1
640373
639868
1
1
640372
640343
1
640363
1
640361
1
640370
1
640339
1
640323
1
640360
640333
640365
1
1
640369
640341
1
1
1
640364
640363
640368
640362
640362
1
640355
6403...

result:

ok 1000000 numbers

Test #22:

score: 0
Accepted
time: 1022ms
memory: 151568kb

input:

1000000 1000000
797897 797911
701410 701414
868242 868248
335308 335313
951737 951740
122233 122242
767448 768738
756033 756041
136033 136042
421604 421606
205530 205559
33387 33402
848923 849108
820686 820725
996799 996876
745298 745404
972785 972807
922900 922918
815937 815945
836876 836884
578928...

output:

651672
651671
651634
651633
1
1
651674
651658
1
1
1
651671
651658
651670
1
651657
1
651656
651657
651664
651660
651660
651659
1
651659
1
651645
651634
651658
1
651656
651657
651649
1
651633
651656
651655
651632
651653
651632
651648
1
1
651648
651631
651647
651645
651644
651638
1
651645
651643
651632...

result:

ok 1000000 numbers

Test #23:

score: 0
Accepted
time: 579ms
memory: 182984kb

input:

1000000 999998
446717 446718
612899 612900
245816 245817
491104 491105
881877 881878
537565 537566
164195 164196
297224 297225
277 278
84739 84740
512122 512123
835405 835406
41111 41112
150631 150632
236550 236551
614186 614187
967156 967157
6773 6774
989302 989303
608751 608752
341454 341455
24339...

output:

999999
999998
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
999958
999957...

result:

ok 1000000 numbers

Test #24:

score: 0
Accepted
time: 433ms
memory: 75232kb

input:

400000 399999
30437 30438
81024 81025
43471 43472
157260 157261
129152 129153
191949 191950
279105 279106
240249 240250
71020 71021
373961 373962
154657 154658
290847 290848
144493 144494
312527 312528
174938 174939
52771 52772
103645 103646
78597 78598
37245 37246
154070 154071
244182 244183
304343...

output:

400000
399999
399998
399997
399996
399995
399994
399993
399992
399991
399990
399989
399988
399987
399986
399985
399984
399983
399982
399981
399980
399979
399978
399977
399976
399975
399974
399973
399972
399971
399970
399969
399968
399967
399966
399965
399964
399963
399962
399961
399960
399959
399958...

result:

ok 400000 numbers

Test #25:

score: 0
Accepted
time: 315ms
memory: 75232kb

input:

400000 399999
224483 224484
232812 232813
106431 106432
396635 396636
140349 140350
227245 227246
75317 75318
123481 123482
229704 229705
140469 140470
68300 68301
258773 258774
326821 326822
359403 359404
47915 47916
340559 340560
213212 213213
159561 159562
388352 388353
313565 313566
288872 28887...

output:

400000
399999
399998
399997
399996
399995
399994
399993
399992
399991
399990
399989
399988
399987
399986
399985
399984
399983
399982
399981
399980
399979
399978
399977
399976
399975
399974
399973
399972
399971
399970
399969
399968
399967
399966
399965
399964
399963
399962
399961
399960
399959
399958...

result:

ok 400000 numbers

Test #26:

score: 0
Accepted
time: 261ms
memory: 75260kb

input:

400000 399999
18368 18369
296352 296353
159047 159048
222 223
291371 291372
210818 210819
20715 20716
73497 73498
45805 45806
388635 388636
333755 333756
327685 327686
191885 191886
392237 392238
280443 280444
205875 205876
399146 399147
372395 372396
155999 156000
363540 363541
4046 4047
259549 259...

output:

400000
399999
399998
399997
399996
399995
399994
399993
399992
399991
399990
399989
399988
399987
399986
399985
399984
399983
399982
399981
399980
399979
399978
399977
399976
399975
399974
399973
399972
399971
399970
399969
399968
399967
399966
399965
399964
399963
399962
399961
399960
399959
399958...

result:

ok 400000 numbers

Test #27:

score: 0
Accepted
time: 1690ms
memory: 183264kb

input:

1000000 999999
698768 698769
107535 107536
138013 138014
952352 952353
564931 564932
779741 779742
402894 402895
814913 814914
291343 291344
515105 515106
64941 64942
161696 161697
690551 690552
41713 41714
905692 905693
648985 648986
176629 176630
811538 811539
742149 742150
892496 892497
862613 86...

output:

1000000
999999
999998
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
99995...

result:

ok 1000000 numbers

Test #28:

score: 0
Accepted
time: 1118ms
memory: 183088kb

input:

1000000 999999
209314 209315
597681 597682
886930 886931
802671 802672
907015 907016
134619 134620
253218 253219
929684 929685
639130 639131
252229 252230
860194 860195
265036 265037
182269 182270
91442 91443
823523 823524
65863 65864
419766 419767
115962 115963
471162 471163
171601 171602
851262 85...

output:

1000000
999999
999998
999997
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
99995...

result:

ok 1000000 numbers

Test #29:

score: 0
Accepted
time: 654ms
memory: 183104kb

input:

1000000 999999
728149 728150
231462 231463
823951 823952
439664 439665
992470 992471
924271 924272
138898 138899
761264 761265
341529 341530
797093 797094
222365 222366
401236 401237
590162 590163
520424 520425
239690 239691
464166 464167
859897 859898
67823 67824
394498 394499
153596 153597
772125 ...

output:

999996
999996
999996
999996
999996
999995
999994
999993
999992
999991
999990
999989
999988
999987
999986
999985
999984
999983
999982
999981
999980
999979
999978
999977
999976
999975
999974
999973
999972
999971
999970
999969
999968
999967
999966
999965
999964
999963
999962
999961
999960
999959
999958...

result:

ok 1000000 numbers

Test #30:

score: 0
Accepted
time: 1492ms
memory: 183292kb

input:

1000000 999999
221164 221165
128857 128858
243129 243130
388281 388282
386941 386942
389694 389695
183059 183060
64529 64530
254992 254993
858746 858747
420367 420368
839902 839903
250411 250412
96995 96996
908649 908650
18802 18803
704837 704838
563071 563072
353816 353817
169964 169965
781259 7812...

output:

999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951
999951...

result:

ok 1000000 numbers

Test #31:

score: 0
Accepted
time: 1704ms
memory: 183064kb

input:

1000000 999999
820353 820354
982527 982528
582183 582184
530203 530204
615438 615439
146538 146539
821342 821343
704317 704318
314327 314328
48457 48458
868443 868444
737146 737147
872110 872111
182447 182448
147227 147228
328154 328155
172533 172534
44604 44605
761305 761306
984 985
60329 60330
531...

output:

999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941
999941...

result:

ok 1000000 numbers

Test #32:

score: 0
Accepted
time: 589ms
memory: 136060kb

input:

1000000 999998
45359 45360
814717 814722
261783 261784
166570 166571
918857 918860
265226 265228
830558 830559
804820 804821
80453 80454
744449 744450
899379 899380
487956 487960
991489 991491
104737 104738
562674 562677
816807 816808
22697 22698
497072 497074
674702 674704
213059 213062
176047 1760...

output:

500000
1
499999
1
499998
499997
1
499996
499995
499994
499993
1
499992
499991
1
1
1
1
1
499990
499989
1
499988
499987
1
1
499986
499985
499984
1
499983
499982
1
499981
499980
1
499979
499978
499977
1
499976
499975
1
499974
1
499973
1
499972
1
1
499971
1
1
1
499970
1
499969
1
499968
499967
499966
499...

result:

ok 1000000 numbers

Test #33:

score: 0
Accepted
time: 600ms
memory: 121428kb

input:

1000000 999995
242219 242232
317400 317405
40115 40122
797823 797825
825550 825553
652988 652991
90572 90583
369750 369760
73910 73911
909354 909357
80301 80309
789208 789211
779223 779226
971099 971103
147253 147264
803867 803873
485579 485582
939588 939606
946241 946245
817644 817649
372919 372922...

output:

1
1
200000
1
1
199999
1
1
1
1
1
199998
199997
199996
1
199995
1
1
1
1
1
1
1
1
1
1
1
199994
1
1
1
1
1
1
1
199993
199992
1
1
199991
1
1
199990
1
1
1
1
1
199989
1
1
1
199988
1
1
199987
1
1
1
1
199986
1
1
1
1
1
1
199985
1
1
1
1
1
199984
1
1
1
199983
1
1
199982
1
1
1
1
1
1
199981
1
1
1
1
1
1
199980
19997...

result:

ok 1000000 numbers

Test #34:

score: 0
Accepted
time: 682ms
memory: 149496kb

input:

1000000 999999
711440 711441
612736 612737
708279 708282
152683 152687
720965 720967
875545 875546
677121 677125
24881 24886
807793 807795
155444 155446
314261 314266
615534 615536
291923 291925
82608 82612
199073 199074
325226 325228
131034 131035
253568 253569
711501 711502
41360 41363
2294 2297
4...

output:

600000
599999
599998
599997
1
599996
599995
599994
599993
599992
599991
1
1
1
599990
599989
599988
1
599987
599986
1
1
1
599985
1
1
1
599984
599983
1
599982
599981
1
1
599980
1
599979
599978
599977
599976
599975
1
599974
599973
1
599972
599971
599970
599969
599968
599967
1
599966
1
599965
599964
599...

result:

ok 1000000 numbers

Test #35:

score: 0
Accepted
time: 612ms
memory: 135892kb

input:

1000000 999997
837641 837642
683145 683154
677008 677010
467244 467247
744613 744614
576534 576538
525434 525437
908324 908326
983783 983788
665270 665271
760850 760854
50207 50208
713396 713401
685223 685234
798036 798038
779630 779631
175089 175090
828839 828840
848865 848866
294992 295003
534731 ...

output:

1
1
1
500000
1
499999
1
499998
1
499997
1
499996
1
1
1
499995
499994
499993
499992
499991
499990
499989
1
1
1
499988
499987
1
1
1
499986
1
499985
499984
1
499983
1
1
1
499982
499981
1
1
499980
499979
499978
1
1
499977
1
499976
1
1
1
499975
1
499974
499973
1
499972
499971
499970
1
499969
1
1
499968
4...

result:

ok 1000000 numbers

Test #36:

score: 0
Accepted
time: 543ms
memory: 118392kb

input:

1000000 799992
563708 563709
343700 343708
44659 44668
622867 622877
957960 957978
27781 27783
815155 815163
493160 493162
597398 597406
287049 287062
449082 449084
765234 765245
394686 394690
679444 679445
836056 836057
959259 959262
295290 295307
913269 913270
589434 589441
16497 16500
590294 5902...

output:

1
1
1
1
1
1
1
1
1
1
1
266666
266665
1
1
1
1
1
1
266664
266663
1
1
266662
1
1
1
1
1
1
1
266661
1
1
266660
1
1
1
266659
266658
266657
1
1
1
1
1
1
266656
1
1
1
1
1
1
1
1
1
266655
1
1
266654
266653
1
1
1
1
1
1
1
1
1
1
1
266652
266651
1
266650
1
1
266649
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
266648
1
1
1
26664...

result:

ok 1000000 numbers

Test #37:

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

input:

2 1
1 2

output:

2
1

result:

ok 2 number(s): "2 1"

Test #38:

score: 0
Accepted
time: 633ms
memory: 143308kb

input:

1000000 999999
632180 632186
83130 83131
776484 776487
122831 122832
193190 193196
177181 177182
903310 903311
208209 208210
593991 593994
579638 579644
352747 352752
185584 185587
563188 563191
803427 803428
691133 691135
888499 888501
324896 324897
706301 706310
337711 337712
688725 688733
166912 ...

output:

570000
569999
1
569998
569997
569996
1
1
569995
569994
1
569993
1
569992
569991
569990
569989
569988
1
569987
569986
569985
569984
1
1
569983
1
1
1
569982
569981
569980
1
1
569979
569978
569977
1
1
1
1
1
1
569976
1
1
569975
569974
1
569973
569972
1
1
569971
1
1
1
569970
569969
1
569968
1
569967
1
1
...

result:

ok 1000000 numbers

Test #39:

score: 0
Accepted
time: 634ms
memory: 146852kb

input:

1000000 999999
217081 217083
208423 208425
436906 436907
432660 432661
241317 241320
934018 934019
723881 723882
636436 636437
926406 926407
45158 45161
60150 60151
88126 88129
160374 160376
449613 449621
59635 59636
985057 985058
779636 779637
404540 404544
961515 961519
91490 91493
212536 212537
3...

output:

1
1
600000
1
1
1
599999
1
599998
599997
1
1
599996
599995
599994
1
599993
599992
599991
599990
1
1
599989
599988
599987
1
599986
599985
599984
1
1
599983
599982
599981
1
599980
1
599979
1
1
599978
599977
599976
1
599975
599974
599973
599972
599971
599970
1
599969
599968
599967
599966
1
599965
1
5999...

result:

ok 1000000 numbers

Test #40:

score: 0
Accepted
time: 624ms
memory: 146496kb

input:

1000000 999999
850209 850211
121706 121707
508144 508146
285698 285700
612159 612160
999290 999291
160805 160806
588657 588659
112033 112034
938670 938671
121653 121657
231725 231729
565880 565884
48093 48094
176416 176417
276586 276587
390210 390212
373715 373717
977114 977116
636616 636617
789192 ...

output:

610000
1
609999
1
609998
1
609997
609996
1
609995
1
1
1
609994
609993
609992
609991
609990
609989
609988
609987
609986
609985
609984
609983
609982
609981
609980
609979
609978
1
609977
609976
609975
1
609974
609973
1
609972
609971
1
609970
609969
1
1
1
1
1
1
1
609968
609967
609966
609965
609964
1
609...

result:

ok 1000000 numbers

Test #41:

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

input:

2 60
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2

output:

2
1

result:

ok 2 number(s): "2 1"

Test #42:

score: 0
Accepted
time: 22ms
memory: 42344kb

input:

500000 1
4651 123165

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 numbers

Extra Test:

score: 0
Extra Test Passed