QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#382321#21529. 动态树(简单版)Isrothy100 ✓264ms8952kbC++233.6kb2024-04-08 12:21:452024-04-08 12:21:46

Judging History

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

  • [2024-04-08 12:21:46]
  • 评测
  • 测评结果:100
  • 用时:264ms
  • 内存:8952kb
  • [2024-04-08 12:21:45]
  • 提交

answer

#include <cstdio>
#include <optional>
#include <vector>
#include <stack>

struct Lct {
    unsigned val, sum;
    bool rev;
    Lct *ch[2], *fa;
    Lct() = default;
    explicit Lct(unsigned val)
        : val(val), sum(val), rev(false), ch{nullptr, nullptr}, fa(nullptr) {}
    Lct *push_up() {
        sum = val;
        if (ch[0] != nullptr) {
            sum ^= ch[0]->sum;
        }
        if (ch[1] != nullptr) {
            sum ^= ch[1]->sum;
        }
        return this;
    }
    bool dir() {
        return fa->ch[1] == this;
    }
    bool is_root() {
        return !fa || (fa->ch[0] != this && fa->ch[1] != this);
    }
    Lct *update_rev() {
        rev ^= 1;
        std::swap(ch[0], ch[1]);
        return this;
    }
    Lct *push_down() {
        if (rev) {
            if (ch[0]) {
                ch[0]->update_rev();
            }
            if (ch[1]) {
                ch[1]->update_rev();
            }
            rev = false;
        }
        return this;
    }
    Lct *rotate(bool f) {
        auto q = ch[f];
        ch[f] = q->ch[!f];
        if (ch[f]) {
            ch[f]->fa = this;
        }
        q->fa = fa;
        if (!is_root()) {
            fa->ch[dir()] = q;
        }
        q->ch[!f] = this;
        fa = q;
        push_up();
        return q;
    }
    Lct *splay() {
        std::stack<Lct *> stk;
        for (auto q = this; !q->is_root(); q = q->fa) {
            stk.push(q->fa);
        }
        while (!stk.empty()) {
            stk.top()->push_down();
            stk.pop();
        }
        push_down();
        while (!is_root()) {
            bool f = dir();
            if (!fa->is_root()) {
                (fa->dir() == f ? fa->fa : fa)->rotate(f);
            }
            fa->rotate(dir());
        }
        return push_up();
    }
    auto access() {
        Lct *p = nullptr;
        for (Lct *q = this; q != nullptr; q = q->fa) {
            q->splay();
            q->ch[1] = p;
            q->push_up();
            p = q;
        }
        return this;
    }
    auto make_root() {
        return access()->splay()->update_rev();
    }
    auto find_root() {
        access()->splay();
        auto q = this;
        while (q->ch[0]) {
            q = q->push_down()->ch[0];
        }
        return q->splay();
    }
};
void link(Lct *p, Lct *q) {
    if (p->find_root() != q->find_root()) {
        p->make_root()->fa = q;
    }
}
void cut(Lct *p, Lct *q) {
    p->make_root();
    q->access()->splay();
    auto r = q->ch[0];
    if (!r) {
        return;
    }
    while (r->ch[1]) {
        r = r->push_down()->ch[1];
    }
    if (r == p) {
        q->ch[0]->fa = nullptr;
        q->ch[0] = nullptr;
    }
    r->splay();
}
std::optional<unsigned> query(Lct *p, Lct *q) {
    if (p->find_root() != q->find_root()) {
        return std::nullopt;
    }
    p->make_root();
    q->access()->splay();
    return q->sum;
}
void update(Lct *p, unsigned val) {
    p->make_root();
    p->val = val;
    p->push_up();
}


int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    std::vector<Lct> v(n + 1);
    for (int i = 1; i <= n; i++) {
        scanf("%u", &v[i].val);
    }
    while (m--) {
        int op, x, y;
        scanf("%d%d%d", &op, &x, &y);
        if (op == 0) {
            printf("%d\n", (int) query(&v[x], &v[y]).value_or(-1));
        } else if (op == 1) {
            link(&v[x], &v[y]);
        } else if (op == 2) {
            cut(&v[x], &v[y]);
        } else if (op == 3) {
            update(&v[x], y);
        }
    }

    return 0;
}

详细

Test #1:

score: 3.33333
Accepted
time: 3ms
memory: 3808kb

input:

1107 4572
234284072 388981847 391448440 477366271 186930123 127662721 932242109 729840760 723502273 878156702 139426149 109192182 895711735 300412478 644823004 751154835 198812322 989657237 667888533 708218412 411100292 639169500 41236867 919203199 712987474 102870210 402909302 646634540 248335431 9...

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
580324260
-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
537311125
-1
-1
-1
-1
-1
-1
-...

result:

ok 953 numbers

Test #2:

score: 3.33333
Accepted
time: 21ms
memory: 4084kb

input:

1478 22168
569881340 405035091 712551926 875554826 406645854 501242919 392949365 237044138 991917769 860919318 602666767 824537289 108866113 139591547 894475719 715734731 605755553 104022820 783400168 675196243 810628270 544549126 785362764 761421196 242193695 758505676 432747106 153822404 399249378...

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
645416247
-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 4610 numbers

Test #3:

score: 3.33333
Accepted
time: 11ms
memory: 3888kb

input:

720 11779
407324044 416057248 215358620 397121163 266598227 672056288 355038763 181861594 133030450 600486797 355994904 811704323 150048063 448794624 613007406 711725050 320509098 8205562 915133242 916173863 732977813 545177862 220442466 670371541 485288754 64702329 364293219 825915255 108377643 463...

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
879514846
-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 2425 numbers

Test #4:

score: 3.33333
Accepted
time: 11ms
memory: 3776kb

input:

152 12209
691802886 215953826 702694628 981148343 975092377 201414321 739162800 21034610 849623247 174894124 308642547 863937500 45592629 757330862 742460999 305369753 932608714 856818299 619604710 74448671 893694992 867421355 443563472 437930232 428483966 96399062 384039387 462514529 756617956 5077...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
631459582
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
691802886
-1
-1
-1
-1
-1
-1
-1
-1
908701981
-1
-1
262115550
-1
-1
-1
-1
-1
-1
578672972
-1
1041534208
-1
1043553714
-1
-1
-1
-1
147605370
-1
397595503
-1
-1
-1
-1
-1
590383248
...

result:

ok 2549 numbers

Test #5:

score: 3.33333
Accepted
time: 27ms
memory: 3920kb

input:

1318 28124
943679982 599490657 14188757 119556929 88798936 61758796 922635692 247956744 77588643 228621429 202899979 544372814 419025104 50246858 364847087 231889637 901747480 923895179 122012732 194794597 617348787 758367265 874514156 205729541 236090640 244220088 523285104 684687814 548533722 3745...

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
991383051
-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 5839 numbers

Test #6:

score: 3.33333
Accepted
time: 12ms
memory: 3856kb

input:

1480 13659
273091642 808945296 126909509 426498595 492288255 110231631 618200926 68848092 665081898 648499844 420071326 268296562 743750189 186575204 243086966 64901921 391261005 789769656 991716058 783849739 765280282 479547496 414236979 290401751 562020126 50771452 972287665 845368884 626840962 93...

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
542153026
-1
-1
-1
-1...

result:

ok 2865 numbers

Test #7:

score: 3.33333
Accepted
time: 21ms
memory: 4084kb

input:

356 22139
431594498 480475890 373890370 228894305 640208283 595505266 344572785 806115258 525318212 7434316 670399747 732635286 366145994 719043994 889163353 481316643 334053518 322709687 488052698 271041133 556891981 503463278 570978111 418427570 706300514 701112253 465872167 343854348 10796679 693...

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
431594498
-1
-1
-1
-1
-1
-1
-1
-1
291525652
-1
-1
-1
-1
-1
-1
304860923
-1
950983334
-1
-1
-1
-1
-1
-1
-1
-1
905950145
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
950983334
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 4743 numbers

Test #8:

score: 3.33333
Accepted
time: 9ms
memory: 4060kb

input:

50 11882
228789343 494106370 464015946 208607989 30612082 935090584 266792064 262927962 349871422 77246250 635002760 18143685 193705091 20037444 532253744 307000673 863700107 9612369 178632626 822516422 896134450 284228663 273573982 285506358 188837597 915857315 544342920 240006709 233771383 5753795...

output:

-1
-1
-1
-1
228789343
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
670051466
-1
-1
-1
-1
-1
-1
-1
-1
-1
496723761
-1
985713324
580651259
221175476
500616147
-1
-1
473374878
234901435
794548406
117992028
723904701
913329970
50730995
30152362
758291106
242059141
-1
781502968
278018382
-1
-1
488505477
765322879
-1
-1...

result:

ok 2482 numbers

Test #9:

score: 3.33333
Accepted
time: 0ms
memory: 4040kb

input:

285 3352
582038534 874354618 806726310 653674385 772297772 295186193 603563610 369069656 585686174 161390241 223515382 798993530 34839848 597858415 632305417 284461915 396182782 530803870 966531980 290709637 319172042 322032367 551133433 955737140 820397047 398986914 822982335 590004131 622683184 21...

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
171271907
-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
969279505
-1
-1
-1
-1
-1
-1
451817480
-1
-1
-1
-1
-1
-1
-1
-1
-1
598515280
-1
-1
-1
-1
-1
-1
-1
-1...

result:

ok 727 numbers

Test #10:

score: 3.33333
Accepted
time: 22ms
memory: 3904kb

input:

1166 23009
121814457 856493653 192559916 211488994 266914699 874209553 409596930 521761274 171258686 488998014 847143010 758487957 241689123 177868187 498361258 531899010 554998825 600016801 931216265 42371861 882290673 500897222 303856950 267299623 856437526 280941209 498838974 461656089 150317958 ...

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
165297198
-1
-1
-1
-1
506580399
-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
283002036
-1
-1
-1
-1
-1
-1
...

result:

ok 4697 numbers

Test #11:

score: 3.33333
Accepted
time: 180ms
memory: 3728kb

input:

12141 173689
883175862 113587309 767153473 63975437 781113122 597898346 57194917 443752894 823881866 755317463 258127039 140087455 586957338 861574464 278039976 554788225 330807907 515220000 65153632 15145921 65920285 567738421 703565961 900932465 942403662 989985109 504981988 365887866 901807269 96...

output:

205927311
246910638
281480631
269809243
781690372
950987578
795168787
368183053
630371934
1054486961
1021757717
858558127
164464388
1022496619
450508741
110947610
382489852
165979918
540041007
123321689
1017540547
819371948
476090321
343101716
893402072
147828785
158172286
709216864
965434582
617574...

result:

ok 30425 numbers

Test #12:

score: 3.33333
Accepted
time: 264ms
memory: 3772kb

input:

7752 250830
597631773 176661818 485156227 625568802 597294590 597435325 857348404 817085090 592523342 8614896 28048251 874404339 485657157 744874559 357367483 825719014 146803400 302383110 309083585 192999319 546762230 544643234 678653429 996556689 849883582 508400456 948668416 371621752 382613848 1...

output:

1050456831
419222368
488997989
336653449
195501599
327111052
434050715
767026564
441213261
790612651
901483462
506139160
932029560
918888522
1017140297
783288126
734884866
510970433
708293187
581833128
1048858256
226770859
994691624
143480183
509282192
150260487
772699110
195486339
1062932224
931947...

result:

ok 44035 numbers

Test #13:

score: 3.33333
Accepted
time: 121ms
memory: 3860kb

input:

11097 120973
718385601 339533874 783190518 128303612 702689502 616478192 506735841 436109766 384473588 700034175 273821837 669150027 365238310 423587058 491529666 864149457 180078920 426454885 204104900 172286883 44243149 820224797 375205789 37076769 485913472 827308047 324202282 784645010 605128383...

output:

16642499
866928015
491290382
20175087
849017793
957892935
442273857
952700538
730567793
379615236
929938784
662388043
605186702
-1
461711891
365621147
232060390
442651249
61302453
980869144
549001283
728452617
229415233
842082189
865820428
944724656
754940323
401832781
807708171
985620155
1004907112...

result:

ok 21100 numbers

Test #14:

score: 3.33333
Accepted
time: 35ms
memory: 3788kb

input:

12431 43068
32882151 121154219 299411874 283222799 337460974 218845250 713830636 148790236 720001343 301205091 440770942 40757843 968133429 923228052 289604734 736186667 587661347 708981435 813775951 874625904 567310343 442698414 997073675 253786372 940362862 304346555 655143795 383344997 990964675 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
13337457
993717516
-1
-1
-1
-1
-1
-1
-1
-1
34654090
811998591
-1
426209469
-1
-1
-1
967833304
-1
912420179
-1
746260061
-1
800182963
-1
-1
-1
948651189
188955015
328205473
456108887
-1
785130150
-1
-1
-1
-1
-1
-1
-1
44978402
429664792
-1
767107290
6...

result:

ok 7512 numbers

Test #15:

score: 3.33333
Accepted
time: 83ms
memory: 3728kb

input:

3569 85355
340989274 973202648 19247282 372176232 424173632 284102222 245830630 76475251 210858782 148008017 411397336 319636788 743115436 301534714 718210948 378595413 108907563 232493902 73794699 941059411 454810198 266083392 313520643 505260936 551350077 898046823 922969746 326259168 864335128 98...

output:

1038885819
513687116
783996476
474637399
968721968
98519686
1066278525
386833047
925192817
163550927
699543770
866728130
359476524
708176528
932361529
274911950
295804743
1049458785
1039689933
531947647
438945604
215009755
926738759
846516082
731835150
807650956
1002936902
314768825
826270779
806937...

result:

ok 14798 numbers

Test #16:

score: 3.33333
Accepted
time: 206ms
memory: 3768kb

input:

8784 197628
236997472 828403196 555774219 209146695 253908918 61752823 460934705 127206200 950931157 904539626 559632554 637355378 154635658 923777011 445506141 558026378 363092290 420469819 26314289 345860659 453597653 870312681 830583024 629506845 264093034 191518281 406456617 458631008 21362144 7...

output:

591639787
421153822
29456765
322502311
482720930
847568115
906836675
551839663
137001206
931685400
609875210
939567620
656781528
750701676
281220702
826797240
267924607
1051164236
65645971
810385756
62567794
787504679
320608356
75272244
263215496
275942803
519968401
31334678
394381072
359367268
1024...

result:

ok 34651 numbers

Test #17:

score: 3.33333
Accepted
time: 199ms
memory: 4056kb

input:

12752 192017
732940391 996566657 646454429 744251174 63138814 179176243 284614360 952508860 453683567 308145294 446610428 622135210 87362818 430538092 168876272 217184978 660711366 578054685 287396340 33037653 390046707 68434008 534397884 708822780 949153297 380706604 402596156 453673915 280396532 1...

output:

551943332
186846837
794230633
477974123
616325420
56425310
486584270
381019607
840579445
193636645
124027339
484162574
10628006
974638964
778469647
500775157
785097108
475942864
621150115
423933377
73151766
399275589
707925405
57047553
919117332
643274700
912752747
452822303
714617274
628218997
7654...

result:

ok 33338 numbers

Test #18:

score: 3.33333
Accepted
time: 160ms
memory: 3800kb

input:

7858 153287
293289490 588964112 217688247 620592747 422433255 257999041 241627372 235576742 791977172 224751651 588263307 173945591 213477227 594399068 54404444 422943469 9418343 714814000 179975901 999368692 518206286 869347173 458616660 728377002 724658548 50884538 715752571 642040443 170785705 65...

output:

677271913
446520805
215358948
58714512
1052617315
693273125
286561190
188899840
245944586
375644962
183197494
37146407
688673115
62568106
832260561
233090786
975654971
936035752
675624045
422237992
891522187
106678894
828401148
199927404
9619696
414466080
715853109
985606241
680298514
720769961
3143...

result:

ok 26866 numbers

Test #19:

score: 3.33333
Accepted
time: 140ms
memory: 4068kb

input:

4529 135866
501087624 220268341 80802717 228455303 801802052 257083126 236800464 258533444 951300442 282155790 647175433 352367278 61151871 183837977 196166101 734996913 18605037 996804531 119099272 834963735 235477918 732059314 722206859 403838549 609425799 164049011 780668781 359667773 794323212 8...

output:

550087483
514892585
287161104
967100808
1008510070
110481808
132471835
305350555
719307232
335814434
614994292
332216949
677852515
669125688
50300393
184354888
568863777
13219134
610902912
419889452
935211758
330759620
654732323
598529392
752308878
433329881
846394627
957068408
353938094
84213526
42...

result:

ok 23820 numbers

Test #20:

score: 3.33333
Accepted
time: 173ms
memory: 3728kb

input:

9851 170182
633242875 976652177 677894597 46060529 207648941 397996028 499801060 808417663 957948925 568024571 224469034 664929538 245866813 510612401 80371256 215382485 745756821 499898703 887314964 45070813 482812731 51500757 45659822 555237038 76056146 46863105 685550623 839901898 449378156 95523...

output:

1022634335
430397305
706802927
792928199
234037317
614326837
19604859
174618205
573247941
328350162
754864326
21056750
405182427
4017809
417413741
123839444
360657272
754875606
257082604
238772157
68404383
24531669
10043144
339387299
1064465494
311607662
712701551
681289734
321677103
742046016
26866...

result:

ok 29748 numbers

Test #21:

score: 3.33333
Accepted
time: 100ms
memory: 6712kb

input:

88850 169104
439219407 133382115 399964746 836979131 645620747 868404708 848737034 58938243 97319244 353759135 1215171 374936400 25992591 115486795 961065913 506783391 82698163 710319392 148676132 729664463 31992473 108553384 67398092 537908730 13852313 155118574 329404335 181982056 930216045 496154...

output:

-1
-1
-1
-1
-1
-1
-1
286229315
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
39280804
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
310698929
-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
43253869
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
562336464
148834...

result:

ok 29538 numbers

Test #22:

score: 3.33333
Accepted
time: 200ms
memory: 7120kb

input:

100686 276212
871549739 136160440 466533606 358530650 457719179 893818276 827731972 592096685 817772116 185943697 800658414 276247893 739963945 449453970 255084909 125882444 880433752 87861892 128476988 454878151 332781894 612647844 180211299 525852359 108314585 679923461 553988700 275471409 2692542...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
340219896
-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
354978419
-1
-1
-1
-1
-1
-1
-1
859899337
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
425105878
-1
-1
-1
-1
858390092
-1
-1
-1
-1
744394094
-1
-1
-1
-1
-1
-1
-1
591...

result:

ok 48007 numbers

Test #23:

score: 3.33333
Accepted
time: 6ms
memory: 5984kb

input:

71770 20174
184364221 351057781 887955123 330631468 743027612 227126917 476703531 191520813 940392109 510754770 82417281 11315438 842595967 295643926 714646834 423509406 136622757 409363353 192817091 758531572 498988374 821290269 480058802 228630481 544012211 715998787 150413218 866446360 8770725 72...

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

result:

ok 3457 numbers

Test #24:

score: 3.33333
Accepted
time: 160ms
memory: 6448kb

input:

87909 232192
840448446 798539162 348086368 316860154 288955927 519879240 53570589 162604471 532434703 847470642 63451649 527196736 821407946 337148398 921744942 398043127 711633512 463878886 799188433 845037842 959124918 445137886 186368588 462692408 497573685 41448214 677400774 935148558 949068213 ...

output:

-1
-1
-1
333627611
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
512505876
-1
-1
184479639
-1
-1
-1
612175597
-1
664606284
880036642
-1
-1
-1
-1
-1
-1
-1
-1
734223002
-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 40731 numbers

Test #25:

score: 3.33333
Accepted
time: 230ms
memory: 5000kb

input:

44255 241838
306372607 145838026 12744333 277579217 799007713 884285235 294354874 427411240 336661027 222390100 487638233 995501988 830486319 382941773 466029436 721504416 171216448 912534314 360374297 574640391 19876216 922985185 155197303 784807491 21513409 573064275 98966826 789945189 32147274 18...

output:

-1
912613622
-1
471020288
-1
-1
-1
409878032
99265915
802876035
-1
-1
-1
-1
228609685
-1
681159646
530072540
258136947
-1
414155644
-1
-1
-1
-1
-1
215720133
-1
-1
-1
1072553668
-1
889370878
148245608
583134719
197918857
-1
853663447
-1
-1
-1
165850600
-1
-1
-1
174081333
584302692
-1
561135778
-1
-1
...

result:

ok 42081 numbers

Test #26:

score: 3.33333
Accepted
time: 54ms
memory: 8748kb

input:

146469 105266
687560601 637165872 441062755 584116731 556695856 515380725 585339808 903253758 805470547 357493584 229359761 134463633 156065639 228688299 743405146 382576767 109098874 880362763 738419828 250624618 44896046 118841397 136431313 685391452 67276138 21915261 172678386 326150466 403210766...

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
707646521
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
101792229
-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 18318 numbers

Test #27:

score: 3.33333
Accepted
time: 119ms
memory: 7684kb

input:

112953 202967
197284148 928802535 251937479 121244058 288345774 975569553 787386847 924361223 298271426 323903146 673044180 333269914 65502445 131967789 189709201 790481915 822824468 89085604 274904826 541555685 623488377 273602551 388677449 492681157 876734975 55064512 716538926 994623213 564098007...

output:

-1
-1
899396878
-1
-1
725845812
-1
-1
-1
-1
482914230
-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 35570 numbers

Test #28:

score: 3.33333
Accepted
time: 52ms
memory: 4604kb

input:

31437 78846
86857094 881151353 593146160 278108630 406500293 686412410 205681479 179868394 172610736 499973030 543936064 747238933 483715739 180460896 268030784 455270700 694413874 463547835 347514079 692026356 346703794 786009263 534100007 934944507 599505567 340940560 261977671 369493300 211771924...

output:

-1
-1
-1
-1
-1
-1
74449735
749348950
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
318452315
-1
-1
-1
94824138
-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
639438054
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
164449356
-1
-1
585007174
-1
-1
8...

result:

ok 13739 numbers

Test #29:

score: 3.33333
Accepted
time: 19ms
memory: 8952kb

input:

146155 19544
53461408 808048986 500213095 878164415 999654460 709393475 228471199 919424252 66896735 788719948 555663678 750644591 481969923 694955785 754663033 991994778 742698390 980213089 151399712 193051784 439140743 388837715 954068772 366730069 465171183 766271313 238952337 735839583 264773286...

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

result:

ok 3413 numbers

Test #30:

score: 3.33333
Accepted
time: 27ms
memory: 7596kb

input:

112696 57845
47907900 343450520 89144409 440456264 667543391 303895553 210902706 781845523 713539202 146722972 969702927 847501427 938093585 911332046 426960599 881156825 49738742 286641108 661570895 153564993 724415099 844706297 133510385 692926046 82731928 239636558 544427419 969092958 564525153 8...

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
37848484
-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 10127 numbers