QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#140277#4557. 温暖会指引我们前行myee100 ✓504ms31340kbC++114.5kb2023-08-15 16:50:212023-08-15 16:50:25

Judging History

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

  • [2023-08-15 16:50:25]
  • 评测
  • 测评结果:100
  • 用时:504ms
  • 内存:31340kb
  • [2023-08-15 16:50:21]
  • 提交

answer

// 那就是希望。
// 即便需要取模,也是光明。

#include <algorithm>
#include <map>
#include <stdio.h>
#include <vector>
typedef long long llt;
typedef unsigned uint;typedef unsigned long long ullt;
typedef bool bol;typedef char chr;typedef void voi;
typedef double dbl;
template<typename T>bol _max(T&a,T b){return(a<b)?a=b,true:false;}
template<typename T>bol _min(T&a,T b){return(b<a)?a=b,true:false;}
template<typename T>T lowbit(T n){return n&-n;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T lcm(T a,T b){return(a!=0||b!=0)?a/gcd(a,b)*b:(T)0;}
template<typename T>T exgcd(T a,T b,T&x,T&y){if(b!=0){T ans=exgcd(b,a%b,y,x);y-=a/b*x;return ans;}else return y=0,x=1,a;}
template<typename T>T power(T base,T index,T mod)
{
    T ans=1%mod;
    while(index)
    {
        if(index&1)ans=ans*base%mod;
        base=base*base%mod,index>>=1;
    }
    return ans;
}
namespace LCT
{
    struct node
    {
        node*son[2],*fath;uint mint,sum,t,w;bol tag;
        node():son{NULL,NULL},fath(NULL),mint(-1u),sum(0),t(-1u),w(0),tag(false){}
        bol ifroot(){return!fath||(this!=fath->son[0]&&this!=fath->son[1]);}
        bol howson(){return this==fath->son[1];}
        voi SWAP(){tag^=1,std::swap(son[0],son[1]);}
        voi pushdown()
        {
            if(tag)
            {
                tag=false;
                if(son[0])son[0]->SWAP();
                if(son[1])son[1]->SWAP();
            }
        }
        voi pushup()
        {
            mint=t,sum=w;
            if(son[0])_min(mint,son[0]->mint),sum+=son[0]->sum;
            if(son[1])_min(mint,son[1]->mint),sum+=son[1]->sum;
        }
        voi update()
        {
            if(!ifroot())fath->update();
            pushdown();
        }
        voi rotate()
        {
            // if(ifroot())return;
            node*f=fath,*ff=fath->fath;bol sk=howson();fath=ff;
            if(!f->ifroot())ff->son[f->howson()]=this;
            if((f->son[sk]=son[!sk]))son[!sk]->fath=f;
            (son[!sk]=f)->fath=this,f->pushup(),pushup();
        }
        voi splay()
        {
            update(),pushup();
            while(!ifroot())
            {
                if(!fath->ifroot())(howson()==fath->howson()?fath:this)->rotate();
                rotate();
            }
        }
        node*access()
        {
            node*p=this,*last=NULL;
            while(p)p->splay(),p->son[1]=last,(last=p)->pushup(),p=p->fath;
            return last;
        }
        voi make(){access()->SWAP();}
        node*find()
        {
            access(),splay();
            node*p=this;while(p->pushdown(),p->son[0])p=p->son[0];
            p->splay();return p;
        }
    }N[400005];
    node*get(uint p){return N+p;}
    voi chgt(node*p,uint t){p->splay(),p->t=t,p->pushup();}
    voi chgw(node*p,uint w){p->splay(),p->w=w,p->pushup();}
    voi link(node*a,node*b){b->make(),b->splay(),b->fath=a;}
    voi split(node*a,node*b){a->make(),b->access(),a->splay();}
    voi cut(node*a,node*b){split(a,b),a->son[1]=b->fath=NULL,a->pushup();}
    bol connected(node*a,node*b){return a->make(),b->find()==a;}
}
uint U[300005],V[300005];
std::map<uint,uint>M;
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
    freopen("QAQ.out","w",stdout);
#endif
    uint q;scanf("%*u%u",&q);
    for(uint t=0;t<q;t++)
    {
        static chr C[15];scanf("%s",C);
        if(*C=='f')
        {
            uint id,t,w;scanf("%u",&id),scanf("%u%u%u%u",&U[id],&V[id],&t,&w),M[t]=id;
            LCT::chgt(LCT::get(id),t),LCT::chgw(LCT::get(id),w);
            bol ok=true;
            if(LCT::connected(LCT::get(U[id]+=q),LCT::get(V[id]+=q)))
            {
                LCT::split(LCT::get(U[id]),LCT::get(V[id])),w=LCT::get(U[id])->mint;
                if(w>t)ok=false;
                else w=M[w],LCT::cut(LCT::get(U[w]),LCT::get(w)),LCT::cut(LCT::get(V[w]),LCT::get(w));
            }
            if(ok)LCT::link(LCT::get(U[id]),LCT::get(id)),LCT::link(LCT::get(V[id]),LCT::get(id));
        }
        else if(*C=='m')
        {
            uint u,v;scanf("%u%u",&u,&v);
            if(!LCT::connected(LCT::get(u+=q),LCT::get(v+=q)))puts("-1");
            else LCT::split(LCT::get(u),LCT::get(v)),printf("%u\n",LCT::get(u)->sum);
        }
        else
        {
            uint id,w;scanf("%u%u",&id,&w),LCT::chgw(LCT::get(id),w);
        }
    }
    return 0;
}

// 那就是希望。
// 即便需要取模,也是光明。

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 1ms
memory: 22252kb

input:

18 50
find 0 1 0 1 8971
find 1 2 0 29 6577
find 2 3 1 7 401
find 3 4 0 2 6697
find 4 5 1 17 7904
find 5 6 5 25 2831
find 6 7 6 21 7325
find 7 8 7 23 6197
find 8 9 8 8 9814
move 7 4
find 9 10 9 30 9947
change 4 3868
find 10 11 10 50 2856
find 11 12 11 46 9634
find 12 13 12 27 6163
find 13 14 13 20 26...

output:

33728
29692
30035
28814
27955
37300
49377
22389
33524
50367
24346
28041
15548
0
27632
25141

result:

ok 16 numbers

Test #2:

score: 5
Accepted
time: 1ms
memory: 23168kb

input:

16 45
find 0 1 0 32 5153
find 1 2 0 26 7298
find 2 3 1 36 8984
find 3 4 1 15 3222
find 4 5 4 13 6421
find 5 6 5 33 9960
find 6 7 6 31 5128
find 7 8 7 34 270
change 2 2713
find 8 9 8 10 7043
move 10 8
find 9 10 9 40 7926
find 10 11 10 12 6336
find 11 12 11 22 5754
change 3 4203
move 13 12
change 3 15...

output:

-1
-1
21509
36992
7298
7926
10752
856
24278
12077
9164
25974

result:

ok 12 numbers

Test #3:

score: 5
Accepted
time: 3ms
memory: 24092kb

input:

975 2965
find 0 1 0 2357 8282
find 1 2 1 2863 1741
find 2 3 1 745 7966
find 3 4 0 1446 8397
find 4 5 1 2496 2632
find 5 6 5 2597 6219
find 6 7 2 2056 1838
find 7 8 7 1527 3927
find 8 9 8 2017 6940
find 9 10 9 2305 2659
find 10 11 10 1124 6393
find 11 12 11 2266 3075
find 12 13 12 2308 4663
find 13 1...

output:

-1
-1
64933
36314
-1
851320
-1
-1
-1
-1
-1
623631
-1
830115
-1
-1
137483
-1
-1
-1
-1
-1
-1
-1
-1
-1
608747
-1
-1
-1
-1
-1
-1
-1
-1
734746
-1
-1
1207221
-1
-1
252155
-1
-1
-1
-1
433231
-1
-1
-1
-1
951618
-1
-1
1160790
843260
-1
-1
-1
-1
358809
301393
-1
-1
-1
896705
-1
-1
-1
-1
741348
307418
-1
-1
-1...

result:

ok 1025 numbers

Test #4:

score: 5
Accepted
time: 8ms
memory: 23476kb

input:

991 2923
find 0 1 0 882 2611
find 1 2 1 183 8911
find 2 3 2 375 353
find 3 4 0 2149 1747
find 4 5 1 32 3921
find 5 6 2 2471 9667
find 6 7 6 1840 3133
find 7 8 7 2601 210
find 8 9 8 449 4753
find 9 10 9 684 7261
find 10 11 10 2786 4213
find 11 12 11 2458 1769
find 12 13 12 631 1273
find 13 14 13 2265...

output:

-1
-1
798528
-1
-1
-1
405058
-1
375076
-1
-1
85966
-1
51347
576770
-1
-1
558744
-1
-1
-1
-1
-1
-1
942463
-1
-1
151895
64096
-1
-1
777358
-1
-1
-1
416206
-1
204878
-1
-1
-1
-1
-1
49250
-1
103979
-1
-1
-1
764105
-1
-1
-1
289070
-1
-1
-1
688637
-1
35972
-1
-1
968447
-1
-1
-1
411123
403984
99045
-1
-1
1...

result:

ok 975 numbers

Test #5:

score: 5
Accepted
time: 4ms
memory: 22544kb

input:

920 2921
find 0 1 0 2002 4557
find 1 2 1 2625 6929
find 2 3 2 1748 5722
find 3 4 3 111 6805
find 4 5 0 2414 1057
find 5 6 5 524 6573
find 6 7 6 2888 7055
find 7 8 7 2553 2227
find 8 9 8 1688 9907
find 9 10 9 579 9899
find 10 11 10 1556 2450
find 11 12 11 274 5229
find 12 13 12 1027 9022
find 13 14 1...

output:

349202
-1
-1
-1
-1
-1
-1
517026
-1
-1
-1
-1
-1
105816
-1
-1
-1
227171
400902
-1
365477
203246
-1
-1
-1
-1
-1
227509
877769
298924
-1
-1
-1
-1
-1
-1
841558
-1
-1
-1
-1
343155
898127
-1
-1
-1
-1
-1
-1
-1
327784
-1
-1
1105761
-1
-1
-1
450721
-1
823405
-1
-1
-1
-1
-1
-1
803985
-1
339308
-1
-1
-1
-1
-1
-...

result:

ok 1008 numbers

Test #6:

score: 5
Accepted
time: 464ms
memory: 31232kb

input:

99554 299101
find 0 1 0 296848 5975
find 1 2 0 284411 172
find 2 3 2 265682 6940
find 3 4 2 254065 6444
find 4 5 1 284961 4783
find 5 6 5 284620 6961
find 6 7 6 271999 2914
find 7 8 7 235039 5112
find 8 9 8 267835 7615
find 9 10 9 284430 2154
find 10 11 10 290993 6656
find 11 12 11 269759 333
find 1...

output:

1619300
2158779
5677965
4398641
5358230
4519771
578272
3962552
2087893
3135294
5882473
3134830
2554626
2432920
4022469
1434527
4121431
3136757
5160946
4147725
2936037
4519767
1497472
5661490
1326190
7744160
2155112
1888932
3766210
2145003
1948082
2568730
2530365
6404710
5408690
324750
5083361
489994...

result:

ok 149770 numbers

Test #7:

score: 5
Accepted
time: 460ms
memory: 30620kb

input:

99048 299363
find 0 1 0 242929 4571
find 1 2 1 287967 6141
find 2 3 0 229090 6428
find 3 4 0 285259 3418
find 4 5 3 239936 8529
find 5 6 5 266733 4270
find 6 7 6 292933 3066
find 7 8 7 144033 9335
find 8 9 8 211479 8970
find 9 10 9 265227 7517
find 10 11 10 287951 4778
find 11 12 11 264858 8445
find...

output:

2101453
2875929
6931222
3726619
7283959
1989092
4395302
5545910
2062341
948983
3530722
2721286
2403650
6119882
3013226
3128079
1767487
1403999
4017951
1415234
206711
2945216
1962333
1143204
1554193
866532
3548215
9796024
1144480
3837186
4587928
1424934
2537233
3871654
1683457
1814054
3332481
5577826...

result:

ok 150791 numbers

Test #8:

score: 5
Accepted
time: 440ms
memory: 30700kb

input:

99258 299082
find 0 1 0 265708 227
find 1 2 1 283871 1819
find 2 3 2 294848 358
find 3 4 1 282487 9069
find 4 5 0 283266 52
find 5 6 5 293519 7967
find 6 7 6 227929 9160
find 7 8 7 287620 9401
find 8 9 4 273643 2315
find 9 10 9 226570 6671
find 10 11 10 293311 9698
find 11 12 11 258063 9764
find 12 ...

output:

4097382
3289628
3943765
5726340
4752691
1478804
2791663
3266328
4866426
3822604
3294970
1933995
1481549
4442989
953641
2315740
2136457
2735632
923695
5536381
2222843
150844
3917845
4021975
2141296
4009574
2874693
5436762
489315
395675
3387842
6396226
2954797
3193439
3594410
1431289
5887188
5145460
4...

result:

ok 150195 numbers

Test #9:

score: 5
Accepted
time: 476ms
memory: 31320kb

input:

99467 299381
find 0 1 0 278770 9878
find 1 2 0 253840 3423
find 2 3 0 268290 8353
find 3 4 3 257148 6487
find 4 5 2 278096 5461
find 5 6 5 282025 1584
find 6 7 6 292590 5309
find 7 8 7 253557 9578
find 8 9 8 287897 4560
find 9 10 9 299369 2141
find 10 11 10 288404 8568
find 11 12 11 284354 2893
find...

output:

2065935
1386285
2341364
4666332
4810230
2584120
4708205
2706134
2194807
4636000
3176564
4451666
2194257
6572086
3180081
4941650
1981049
3944276
1517521
1791734
2502576
3927923
2634588
2315646
2581201
1404567
2660470
1618386
3552833
1202325
5103634
3290232
3151822
4070013
2539607
2995852
2800944
2020...

result:

ok 150181 numbers

Test #10:

score: 5
Accepted
time: 504ms
memory: 30800kb

input:

99677 299835
find 0 1 0 283002 1926
find 1 2 1 277300 8946
find 2 3 1 239332 3066
find 3 4 0 207042 8501
find 4 5 0 296242 8953
find 5 6 5 289908 2973
find 6 7 6 285517 7627
find 7 8 7 279127 7375
find 8 9 8 240021 880
find 9 10 9 288568 5888
find 10 11 10 286815 5062
find 11 12 11 278333 5871
find ...

output:

3658576
1238412
1212403
1420801
2719533
2875593
2102823
6918662
6087786
6978817
3885568
4171558
3491004
2398065
1650752
3452461
364330
3520399
4162262
959045
3167174
3640884
3717058
2176201
4891485
4247074
4421772
3548250
3895097
5447791
4433854
1235304
1847410
4179058
3953018
2248579
5379205
231879...

result:

ok 150320 numbers

Test #11:

score: 5
Accepted
time: 430ms
memory: 30940kb

input:

99887 299288
find 0 1 0 254068 6132
find 1 2 1 299033 340
find 2 3 2 253021 1818
find 3 4 1 284299 1066
find 4 5 3 223537 2309
find 5 6 5 267712 8558
find 6 7 6 298422 9734
find 7 8 7 285129 9369
find 8 9 8 279090 7299
find 9 10 9 239643 233
find 10 11 10 286085 1368
find 11 12 11 245767 6197
find 1...

output:

3894880
4397175
1476248
2231613
847282
3328842
5867838
1946027
1983902
3115934
3059060
3281810
3518350
2501559
4379648
2156904
3575372
2571269
3905781
3406693
2149341
1365458
1474216
473095
540731
5077092
3284087
2254127
1072552
1688045
565051
1830488
2911090
812131
1413115
5217740
3670648
2328782
3...

result:

ok 119701 numbers

Test #12:

score: 5
Accepted
time: 430ms
memory: 30604kb

input:

99096 299007
find 0 1 0 280654 9347
find 1 2 1 271384 7588
find 2 3 1 241975 2654
find 3 4 1 264835 4594
find 4 5 1 298735 3465
find 5 6 5 292769 3845
find 6 7 6 271382 8501
find 7 8 7 291014 3580
find 8 9 8 198534 2715
find 9 10 9 285249 7889
find 10 11 10 292556 8814
find 11 12 11 295882 6486
find...

output:

3485915
3483668
2845151
2908448
3230503
3239351
1760019
1725280
3364543
3063487
1239754
4169263
2825934
1598704
2332339
2576388
1186928
2285453
3690473
4600261
3293214
676518
3162255
1732725
2216877
2798515
3150449
4099784
2635255
1669491
2495950
4165868
4462782
3320745
1962329
2778444
590756
134280...

result:

ok 120267 numbers

Test #13:

score: 5
Accepted
time: 418ms
memory: 30720kb

input:

99538 299461
find 0 1 0 292022 882
find 1 2 0 296894 1319
find 2 3 2 245421 3152
find 3 4 1 242527 8068
find 4 5 2 238559 6858
find 5 6 5 262322 3140
find 6 7 6 252041 3443
find 7 8 7 196838 1420
find 8 9 8 269649 3514
find 9 10 9 209138 5048
find 10 11 10 285643 6301
find 11 12 11 189649 6619
find ...

output:

1369462
5255393
4620661
2826761
2137915
6290317
5466187
1580726
1212910
2602660
1574779
5022685
5190081
1616400
5965559
1007376
4672547
3499283
5535570
1034419
1281315
3026084
1290839
4210852
5827700
3779653
6120199
2583319
1992001
5023683
2297183
2297787
3409430
1284585
4429281
2940079
4190208
1218...

result:

ok 120082 numbers

Test #14:

score: 5
Accepted
time: 433ms
memory: 30728kb

input:

99695 299106
find 0 1 0 202196 8812
find 1 2 0 255019 5366
find 2 3 2 262926 9548
find 3 4 2 266387 8730
find 4 5 0 286926 1554
find 5 6 5 206512 9629
find 6 7 4 282100 3059
find 7 8 7 297872 6036
find 8 9 8 273485 7615
find 9 10 9 278997 8955
find 10 11 9 286122 7764
find 11 12 11 281170 468
find 1...

output:

2770939
921079
4219526
3552689
2131771
1597319
3064673
2727651
2976039
3525657
1056419
1147151
2220598
3337233
2618850
2130859
2316722
2863329
3037907
2718464
2138857
1808738
2588464
143395
3015716
2342542
3007110
3782956
3407501
1883530
2845802
689138
4193784
1453515
2743993
1899819
1926182
4857318...

result:

ok 119952 numbers

Test #15:

score: 5
Accepted
time: 448ms
memory: 31184kb

input:

99905 299560
find 0 1 0 279284 9413
find 1 2 0 273856 6697
find 2 3 0 254812 7091
find 3 4 1 277361 1208
find 4 5 3 293463 1538
find 5 6 5 285438 1291
find 6 7 6 274888 898
find 7 8 7 288662 3259
find 8 9 8 274404 7794
find 9 10 9 282099 862
find 10 11 10 262871 7124
find 11 12 7 288614 2531
find 12...

output:

3032701
2878750
-1
6452308
-1
-1
-1
-1
1920991
-1
-1
-1
-1
-1
-1
-1
3811230
-1
-1
2225893
-1
8390838
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4514842
-1
7239780
-1
-1
-1
-1
-1
6755428
-1
-1
-1
-1
6447155
-1
-1
-1
-1
-1
-1
-1
-1
7898450
-1
1962917
-1
-1
1948095
-1
-1
-1
-1
-1
-1
-1
-1
3647715
-1
-1
-1
-1
-1
-1
...

result:

ok 99927 numbers

Test #16:

score: 5
Accepted
time: 435ms
memory: 30728kb

input:

99114 299013
find 0 1 0 268107 1756
find 1 2 0 292611 1111
find 2 3 0 268302 1118
find 3 4 1 240592 4359
find 4 5 1 173363 4415
find 5 6 5 239683 8525
find 6 7 5 278794 7668
find 7 8 7 270227 3296
find 8 9 5 290675 3377
find 9 10 9 202507 7590
find 10 11 10 286516 5743
find 11 12 11 292964 2320
find...

output:

-1
-1
6391402
-1
-1
-1
-1
-1
-1
4219351
-1
-1
-1
-1
3878341
-1
-1
-1
-1
1955943
-1
-1
-1
-1
-1
-1
-1
-1
-1
2925840
771976
-1
-1
-1
3257508
-1
-1
2766022
-1
-1
-1
-1
-1
2443513
4440749
-1
1382479
-1
-1
-1
2504425
5287870
-1
-1
-1
4438948
-1
-1
-1
3025136
-1
-1
-1
4058534
3992538
-1
1717245
-1
-1
-1
-...

result:

ok 99367 numbers

Test #17:

score: 5
Accepted
time: 444ms
memory: 30864kb

input:

99503 299659
find 0 1 0 298947 3796
find 1 2 0 294175 7692
find 2 3 1 256027 5615
find 3 4 0 275428 7354
find 4 5 1 279002 4899
find 5 6 5 262444 1886
find 6 7 6 267634 9947
find 7 8 7 291739 7026
find 8 9 8 285820 8315
find 9 10 9 278788 1164
find 10 11 10 292117 7214
find 11 12 11 226070 2676
find...

output:

1798464
2746268
3096978
-1
-1
-1
4284758
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2374138
2724929
-1
-1
-1
-1
3911770
2217321
-1
-1
-1
-1
-1
-1
-1
-1
-1
3554709
3478706
4735152
-1
-1
-1
-1
2969528
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1928371
1900322
2918974
-1
-1
-1
-1
-1
3675911
-1
-1
-...

result:

ok 99871 numbers

Test #18:

score: 5
Accepted
time: 486ms
memory: 31340kb

input:

99481 299113
find 0 1 0 291292 9252
find 1 2 0 287034 4125
find 2 3 1 295552 302
find 3 4 3 274101 7234
find 4 5 3 290245 6909
find 5 6 5 290073 2336
find 6 7 6 272111 3351
find 7 8 7 269014 2504
find 8 9 5 253609 7687
find 9 10 6 296181 7819
find 10 11 10 211821 3851
find 11 12 11 287763 2619
find ...

output:

-1
-1
-1
3908085
-1
-1
-1
-1
-1
3636924
4029987
-1
-1
-1
-1
2825343
-1
-1
-1
2972470
-1
4078622
-1
-1
-1
-1
-1
-1
-1
3533152
-1
4533102
-1
1765672
-1
-1
-1
-1
3604144
5877083
-1
-1
-1
3142641
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
2519033
3878871
2374733
-1
-1
-1
-1
-1
2202817
-1
-1
738509
3900232
-1
4542...

result:

ok 99531 numbers

Test #19:

score: 5
Accepted
time: 440ms
memory: 31324kb

input:

99870 299758
find 0 1 0 163268 2036
find 1 2 0 297179 2734
find 2 3 2 232470 3959
find 3 4 3 251204 252
find 4 5 3 289658 9188
find 5 6 5 295849 1127
find 6 7 6 290651 2523
find 7 8 7 299184 8605
find 8 9 8 293780 7310
find 9 10 9 246766 2886
find 10 11 10 296432 5977
find 11 12 11 293996 5919
find ...

output:

1101431
4161036
-1
-1
-1
-1
-1
-1
-1
2422590
-1
-1
-1
5238488
-1
-1
-1
4977061
3106113
-1
-1
-1
2141053
-1
-1
-1
-1
-1
-1
1718581
-1
-1
-1
3454848
-1
-1
2273094
-1
-1
3700699
-1
-1
-1
2848879
4700615
-1
-1
-1
-1
-1
2673582
-1
-1
-1
-1
-1
4169349
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1779139
-1
4711043
-1
-1...

result:

ok 99857 numbers

Test #20:

score: 5
Accepted
time: 468ms
memory: 31312kb

input:

99312 299212
find 0 1 0 229838 6507
find 1 2 0 296207 433
find 2 3 2 255269 9682
find 3 4 1 252044 7903
find 4 5 2 295930 4399
find 5 6 5 285668 8258
find 6 7 6 241974 2250
find 7 8 7 297398 9108
find 8 9 8 293088 6560
find 9 10 9 295572 9182
find 10 11 10 287701 9225
find 11 12 11 291455 7183
find ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
5076791
-1
-1
-1
-1
-1
-1
-1
-1
-1
2379572
-1
-1
-1
-1
-1
-1
-1
-1
4135790
-1
-1
-1
-1
-1
-1
-1
4397368
-1
-1
-1
221178
-1
-1
3330957
-1
-1
-1
-1
-1
3753514
2650025
5675877
-1
-1
3160709
-1
-1
-1
-1
-1
-1
2591448
1954729
-1
5476127
-1
3274760
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok 99882 numbers

Extra Test:

score: 0
Extra Test Passed