QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106832#4526. 遥远的星系myee100 ✓598ms3468kbC++111.7kb2023-05-19 14:21:202023-05-19 14:21:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-19 14:21:22]
  • 评测
  • 测评结果:100
  • 用时:598ms
  • 内存:3468kb
  • [2023-05-19 14:21:20]
  • 提交

answer

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

#include <algorithm>
#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;
}
// Heaven and Earth... My guiding star...
uint F[100005];llt W[100005],G[100005];
voi upd(uint p){if(p!=F[p])upd(F[p]),W[p]+=W[F[p]],F[p]=F[F[p]];}
int main()
{
#ifdef MYEE
    freopen("QAQ.in","r",stdin);
    freopen("QAQ.out","w",stdout);
#endif
    uint n,q,g=0;scanf("%u%u%*u%*u",&n,&q);
    for(uint i=0;i<n;i++)F[i]=i;
    while(q--)
    {
        uint op,u,v,a,b;llt w;
        scanf("%u%u%u%lld%u%u",&op,&u,&v,&w,&a,&b);
        u=(u+(a&g)-1)%n,v=(v+(b&g)-1)%n;
        upd(u),upd(v);
        w-=W[u],u=F[u],w+=W[v],v=F[v];
        if(op)
            if(u==v&&(!w||(G[u]&&!(w%G[u]))))puts("1"),g=g<<1|1;else puts("0"),g<<=1;
        else
            if(u==v)G[u]=gcd(G[u],w>0?w:-w);else W[u]=w,F[u]=v,G[v]=gcd(G[u],G[v]);
    }
    return 0;
}

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

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

詳細信息

Test #1:

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

input:

5 20 3 3
0 4 5 -6 543136755 532338766
0 4 2 -4 768148048 57819153
1 3 3 0 218761306 129341953
0 1 4 -16 381566777 150847889
0 2 3 1 853677468 820144777
1 4 2 -12 377539894 711851152
0 3 3 -6 555386297 720246729
1 2 4 13 922095250 223129153
0 3 1 16 486654731 270250269
1 2 4 1 833629341 598024653
1 5...

output:

1
1
1
1
1
1
1
1
0
1

result:

ok 10 numbers

Test #2:

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

input:

50 200 3 3
0 12 7 12 269784999 792487551
0 33 22 -18 79936769 766226657
0 14 47 -16 15310364 561008502
0 11 16 -10 660145887 396144960
0 27 23 16 410165872 1055931393
0 41 43 2 844075946 997074484
0 48 12 -12 823677091 195984037
0 15 3 -17 1051444788 910647166
0 14 41 18 99297727 726005997
0 43 10 1...

output:

0
1
0
1
0
1
1
1
0
0
0
1
0
0
1
1
1
1
0
0
0
0
1
0
1
0
1
1
0
0
0
1
0
1
0
0
0
0
1
0
1
1
1
1
1
0
1
1
1
1
1
0
1
0
1
1
0
1
1
0
1
1
1
1
1
1
0
1
1
0
1
1
1
1
0
1
1
1
1
1
1
1
1
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
1
1

result:

ok 100 numbers

Test #3:

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

input:

100000 1000000 2 0
0 83547 2084 854082633314 0 0
0 70191 75895 -36619489598 0 0
0 41786 31987 -161986154853 0 0
0 28550 98484 -800152931624 0 0
0 52154 3602 -311154622437 0 0
0 37276 11248 360987185461 0 0
0 7921 46576 681889448336 0 0
0 51590 99637 122932144169 0 0
0 92643 84090 -354507875450 0 0
0...

output:

1
0
1
0
1
0
0
0
0
1
1
1
1
1
1
1
0
0
0
1
1
1
0
0
1
0
0
1
1
0
0
0
1
1
0
0
0
1
1
1
1
0
1
1
1
0
1
1
0
1
1
1
1
0
1
1
0
0
1
0
0
0
0
0
0
1
1
0
0
1
1
0
1
0
1
1
0
0
0
1
0
0
1
1
0
0
0
1
0
1
1
1
1
1
1
1
1
0
1
0
0
0
1
0
0
1
0
1
0
1
0
1
0
1
1
1
1
1
1
1
0
0
0
1
0
0
0
1
0
1
0
1
1
0
0
1
1
1
1
1
1
0
1
1
1
1
0
0
1
0
...

result:

ok 900047 numbers

Test #4:

score: 5
Accepted
time: 516ms
memory: 3320kb

input:

100000 1000000 3 0
0 78193 92026 -582220600543 256889562 341780751
0 39130 11802 279525953614 990460948 10777477
0 5705 61399 -290152827339 764515860 946392167
0 77336 72630 -775961494021 792529930 145357291
0 15167 44218 -335507545021 89318988 47301583
0 23026 46247 -430011923101 412181171 99584378...

output:

1
0
0
0
1
0
1
0
1
0
1
0
0
0
0
1
0
1
0
0
0
0
1
0
1
1
0
1
1
1
0
0
0
0
1
1
0
0
0
1
1
1
0
1
1
1
0
1
0
0
1
1
0
0
1
1
0
1
0
0
0
0
1
0
0
1
1
1
1
0
1
1
1
1
0
0
1
1
1
1
1
1
1
0
1
1
1
1
0
0
0
1
0
1
1
1
1
0
0
0
1
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
0
1
1
0
0
1
0
0
0
1
0
0
0
1
0
1
0
1
1
1
0
0
1
0
0
0
1
1
0
1
1
0
0
1
...

result:

ok 900047 numbers

Test #5:

score: 5
Accepted
time: 475ms
memory: 3324kb

input:

100000 1000000 0 1
0 61781 16318 226643271876 0 0
0 62191 29681 -878216602946 0 0
0 99498 91075 -141462036632 0 0
0 29405 60955 -743558230057 0 0
0 6273 80879 -98062863356 0 0
0 78787 61955 736852515966 0 0
0 40174 80659 -52382501127 0 0
0 12762 48042 -31195504380 0 0
0 27341 35653 -296861328809 0 0...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 900046 numbers

Test #6:

score: 5
Accepted
time: 474ms
memory: 3424kb

input:

100000 1000000 2 1
0 21504 44623 -29652362741 0 0
0 47703 95171 374493324444 0 0
0 44436 14251 -18479785033 0 0
0 74546 100 896557221632 0 0
0 3359 44477 928245978977 0 0
0 69680 27051 -424102036025 0 0
0 62405 71301 704750491318 0 0
0 69765 2754 -884611347364 0 0
0 22844 49240 -84794852238 0 0
0 99...

output:

1
1
1
1
0
0
1
0
1
1
0
0
1
0
1
0
1
0
0
0
1
1
1
1
1
0
0
0
0
1
0
1
0
1
0
1
0
0
0
1
0
0
0
0
0
1
1
0
1
1
0
0
1
1
0
1
0
1
0
0
0
0
0
1
1
1
1
1
0
0
1
1
1
0
1
0
1
0
0
0
0
1
0
1
0
0
1
1
1
0
1
1
0
1
0
1
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
1
1
0
0
0
0
0
1
1
0
0
0
0
0
1
1
1
0
1
0
1
0
1
0
1
0
0
0
0
0
0
1
1
1
1
0
1
0
...

result:

ok 900046 numbers

Test #7:

score: 5
Accepted
time: 513ms
memory: 3444kb

input:

100000 1000000 3 1
0 49655 71651 437344492075 196330872 1035541895
0 99927 19150 658745332011 1071005343 451234717
0 10476 58910 191890573616 785856787 132694559
0 89942 4045 946822548798 947994818 249768733
0 70068 66139 663313317746 995798737 661457319
0 19550 17794 -925648806386 1052180133 315619...

output:

0
0
1
0
1
1
0
0
0
1
0
0
0
0
1
0
0
0
1
0
1
1
1
0
1
0
1
1
1
0
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
0
1
1
0
1
0
0
1
0
1
0
1
0
1
1
0
0
1
1
0
0
1
0
0
0
1
0
1
0
1
1
1
0
1
0
0
0
1
1
1
0
1
0
1
1
0
1
0
1
0
0
1
0
1
1
1
1
0
0
0
1
0
0
1
1
0
1
0
1
0
1
1
1
0
1
1
0
1
1
1
1
0
1
0
0
0
0
1
1
0
0
1
0
0
0
0
1
1
0
0
1
0
...

result:

ok 900046 numbers

Test #8:

score: 5
Accepted
time: 598ms
memory: 3328kb

input:

100000 1000000 3 1
0 18300 24616 -979189149904 498538511 408727476
0 26244 93670 -911781403468 852135018 800127399
0 22692 12876 668474319756 106495498 593093942
0 64998 59158 670562746957 185214635 579893466
0 84137 85060 203907048138 305657216 120515858
0 73448 36540 -243101259203 783536110 377638...

output:

0
1
0
1
0
0
0
0
1
0
1
0
1
1
1
1
0
0
1
1
1
1
1
0
0
1
1
0
0
1
1
1
0
1
1
0
0
0
1
1
0
1
1
0
0
0
1
1
1
0
0
0
0
0
0
0
1
0
0
1
0
1
1
0
1
1
1
1
0
1
0
1
0
0
1
1
1
0
1
0
1
0
1
0
1
1
1
1
1
0
1
1
1
0
0
0
0
1
1
0
1
1
1
0
1
0
1
1
0
1
1
1
1
0
0
0
1
0
0
0
1
1
1
1
1
0
1
1
1
1
0
0
0
0
1
0
0
0
0
0
1
0
1
0
1
1
1
0
0
0
...

result:

ok 900046 numbers

Test #9:

score: 5
Accepted
time: 439ms
memory: 3264kb

input:

100000 1000000 0 2
0 33224 32681 -993538598807 0 0
0 98429 59969 -33134935045 0 0
0 18654 99005 -335502786319 0 0
0 67899 20398 -467425638356 0 0
0 15741 52019 143937332903 0 0
0 22236 98944 533061439885 0 0
0 31582 45793 -133060029159 0 0
0 12328 82116 -270562861201 0 0
0 20117 66011 -803062347410 ...

output:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 900034 numbers

Test #10:

score: 5
Accepted
time: 455ms
memory: 3284kb

input:

100000 1000000 2 2
0 27307 74259 -468525184528 0 0
0 60614 2761 197973427178 0 0
0 14231 33409 787824934975 0 0
0 45308 24315 -732225268731 0 0
0 3928 37546 758727907205 0 0
0 46089 52093 -261033311181 0 0
0 93856 16364 921223720190 0 0
0 67666 17308 71651404044 0 0
0 37162 43574 872769780169 0 0
0 ...

output:

1
1
1
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
1
1
1
1
0
0
1
0
1
1
1
0
1
1
1
0
1
1
1
1
1
1
0
0
0
1
0
0
0
1
1
1
0
1
0
1
1
1
1
0
0
1
0
1
0
0
1
1
1
0
0
0
1
0
0
0
0
0
0
0
0
1
1
1
0
0
1
0
0
1
1
1
1
0
0
0
1
0
1
1
0
1
1
0
0
1
0
1
1
0
0
1
0
1
0
1
0
1
1
0
1
0
1
1
1
0
0
0
1
0
1
1
0
1
0
1
0
0
1
0
1
1
0
0
...

result:

ok 900037 numbers

Test #11:

score: 5
Accepted
time: 461ms
memory: 3412kb

input:

100000 1000000 2 2
0 54805 83543 -232591844282 0 0
0 96458 16852 772386443419 0 0
0 34879 97350 -439742364983 0 0
0 49915 3079 -980948182584 0 0
0 24841 13229 -478475118142 0 0
0 60276 31344 -535199010851 0 0
0 72167 36097 -140676067109 0 0
0 54083 79364 -973297205753 0 0
0 85499 77003 -313344460996...

output:

0
0
0
0
1
1
0
1
1
1
1
1
0
1
1
0
0
1
0
0
0
1
0
1
1
0
1
1
0
1
1
0
1
1
1
1
0
0
0
0
1
0
0
0
0
0
1
1
1
1
1
1
1
0
1
0
1
0
1
0
1
0
0
1
0
1
1
0
0
1
1
1
1
0
0
0
0
1
1
1
1
0
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
1
1
0
0
0
0
0
1
1
0
1
1
1
0
1
0
1
1
0
1
0
1
1
0
1
1
1
0
1
1
1
0
1
1
0
1
1
0
0
0
0
0
1
0
1
0
0
0
0
0
1
...

result:

ok 900032 numbers

Test #12:

score: 5
Accepted
time: 521ms
memory: 3408kb

input:

100000 1000000 3 2
0 75699 42312 936435768150 872486919 336657549
0 71463 53369 737026218537 326238698 584943139
0 53106 10211 -585892295586 938028984 392580225
0 86445 4383 413106064291 503577807 273842491
0 91133 19574 -867726596492 781343534 275210835
0 13840 26064 6316318983 937653032 12489287
0...

output:

1
1
1
0
1
1
0
1
0
1
0
1
0
1
1
0
0
1
1
0
0
0
1
0
1
0
0
0
0
1
0
1
0
0
1
0
0
0
0
1
0
0
0
1
0
1
0
0
0
1
1
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
1
0
0
1
0
1
1
1
1
1
1
1
0
0
0
0
0
1
0
1
1
1
0
1
1
0
1
1
1
0
1
1
1
1
1
1
1
0
1
0
1
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
0
1
1
1
1
0
1
0
0
1
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 900035 numbers

Test #13:

score: 5
Accepted
time: 499ms
memory: 3380kb

input:

100000 1000000 0 3
0 78271 45987 80302049851 0 0
0 77458 41310 -158133688547 0 0
0 18095 83325 446062255629 0 0
0 51651 5760 -829244001623 0 0
0 88636 67487 897475785510 0 0
0 2079 7470 497746935180 0 0
0 17918 40178 508582265690 0 0
0 46471 89861 -953429558430 0 0
0 88296 89245 587775672821 0 0
0 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
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
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

Test #14:

score: 5
Accepted
time: 450ms
memory: 3436kb

input:

100000 1000000 0 3
0 63434 89944 -926401131116 0 0
0 34286 43006 -268680877469 0 0
0 7132 59917 230230624765 0 0
0 31178 2318 943405989328 0 0
0 62552 41227 -986147016273 0 0
0 1844 91087 -720251137208 0 0
0 46178 97926 -41743325054 0 0
0 87217 85187 77401803972 0 0
0 25609 63308 -16128101616 0 0
0 ...

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

Test #15:

score: 5
Accepted
time: 488ms
memory: 3420kb

input:

100000 1000000 2 3
0 16979 34300 451442441207 0 0
0 75159 98050 -972282445874 0 0
0 66678 13054 41705620848 0 0
0 71004 62271 549120199374 0 0
0 59501 87457 -639834863100 0 0
0 65574 72993 867136919860 0 0
0 58877 82910 -252144242819 0 0
0 45434 86548 -495537251693 0 0
0 54685 93283 448760591715 0 0...

output:

1
0
0
0
1
1
0
0
1
0
0
0
0
0
1
1
1
0
1
1
0
0
1
0
0
0
1
1
1
1
0
0
1
0
0
1
0
0
1
0
1
1
0
1
1
0
1
1
1
0
1
0
1
1
1
1
0
1
0
0
1
1
1
1
0
1
0
1
1
1
1
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
1
1
1
1
0
1
0
1
1
1
0
1
1
1
1
0
1
1
1
0
0
1
0
0
1
0
0
1
1
0
1
1
0
1
0
1
0
1
1
1
1
0
0
1
0
1
0
1
0
0
0
1
1
1
0
0
1
1
1
0
1
0
1
0
...

result:

ok 500000 numbers

Test #16:

score: 5
Accepted
time: 473ms
memory: 3424kb

input:

100000 1000000 2 3
0 220 50455 169565780595 0 0
0 63573 94510 -607046506884 0 0
0 67457 15287 336802352938 0 0
0 15953 26888 -291254124872 0 0
0 38580 21289 972362678899 0 0
0 69819 69423 -332861461809 0 0
0 57902 40314 823557176223 0 0
0 71795 39857 -546932165154 0 0
0 16867 42614 -226302378006 0 0...

output:

0
0
0
1
1
0
1
1
1
1
1
0
0
1
0
1
0
1
1
0
0
1
1
0
0
1
0
1
0
0
0
0
1
1
0
1
1
0
1
0
0
1
1
0
1
0
1
0
1
1
0
0
0
1
1
1
0
0
0
1
1
1
1
1
0
1
1
0
1
0
1
0
0
0
0
0
0
1
0
0
1
0
1
1
0
0
0
1
0
0
1
0
0
0
1
1
0
1
1
1
0
1
1
0
0
1
1
1
0
0
0
0
1
1
0
0
0
1
1
1
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
0
1
1
0
1
1
0
0
0
0
0
1
0
0
...

result:

ok 500000 numbers

Test #17:

score: 5
Accepted
time: 484ms
memory: 3384kb

input:

100000 1000000 2 3
0 20651 85401 -244110234148 0 0
0 97590 49046 -871521334468 0 0
0 8482 70798 -518210673819 0 0
0 47385 79873 654657636807 0 0
0 19413 11238 602722320899 0 0
0 17298 76437 282135109097 0 0
0 67029 41591 889591293185 0 0
0 76719 69653 -321752627779 0 0
0 41935 76338 321764002838 0 0...

output:

1
0
1
0
1
0
0
0
0
1
1
0
1
0
0
1
1
1
0
0
1
1
0
0
0
0
0
0
1
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
1
1
0
1
0
0
0
1
1
1
1
1
0
1
0
1
0
1
1
0
1
1
1
0
0
0
1
1
0
1
1
0
0
0
0
1
0
0
1
0
0
0
1
0
0
0
0
1
0
1
0
0
0
1
1
0
1
0
1
1
0
0
1
0
0
0
0
0
1
0
0
0
1
1
1
1
0
1
0
0
1
0
0
1
0
1
0
0
1
0
1
0
1
1
0
1
0
0
0
1
0
0
1
1
1
0
...

result:

ok 500000 numbers

Test #18:

score: 5
Accepted
time: 592ms
memory: 3412kb

input:

100000 1000000 3 3
0 53472 39411 -562315173541 773001292 383449318
0 19711 82730 603534706258 81178625 394660092
0 28260 10569 356276483773 1018094308 549694543
0 24084 48139 157158428465 280084348 230605456
0 85813 23727 -875740208475 194258232 1019234180
0 63827 13629 -100318515785 1002679609 4213...

output:

1
0
0
1
0
1
1
0
0
1
1
0
0
0
1
1
1
0
0
0
0
1
0
1
0
1
0
0
1
1
0
0
0
1
0
0
0
0
0
0
0
1
1
0
0
1
0
0
1
1
1
0
0
0
0
0
0
1
1
0
0
0
0
0
1
0
0
0
0
1
1
0
1
1
1
0
0
1
1
0
1
0
0
1
0
0
1
0
0
1
0
1
1
1
0
1
1
1
1
0
0
0
0
0
1
1
1
0
0
0
0
1
1
0
0
0
0
0
1
0
1
0
1
1
1
0
1
1
0
0
0
0
1
0
1
0
1
0
0
1
0
1
1
0
0
1
1
1
0
0
...

result:

ok 500000 numbers

Test #19:

score: 5
Accepted
time: 588ms
memory: 3468kb

input:

100000 1000000 3 3
0 3965 81591 -465560581572 201691882 570684339
0 71268 43441 -534286275997 884992078 97750711
0 9720 43889 -547759041352 812185829 516563988
0 68225 34948 -298967158971 458965784 645176408
0 39586 37544 742729811072 14760127 862425392
0 24238 15881 -566527035014 53179618 101657930...

output:

1
1
1
1
1
0
1
0
0
1
0
1
1
0
0
1
1
1
0
0
1
0
0
1
1
1
1
0
0
0
0
0
1
0
0
0
1
1
1
0
0
1
1
1
0
1
1
1
0
1
0
1
1
1
1
0
0
0
0
0
1
0
0
1
1
1
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
1
1
1
0
1
1
1
0
0
0
1
1
1
1
0
0
1
1
0
1
0
0
1
0
1
0
1
0
0
1
0
0
0
0
1
0
0
0
1
1
0
0
1
1
1
0
1
0
0
0
1
0
1
0
1
0
1
1
0
0
1
0
0
0
1
1
0
0
0
...

result:

ok 500000 numbers

Test #20:

score: 5
Accepted
time: 591ms
memory: 3316kb

input:

100000 1000000 3 3
0 30820 38019 395535792704 965707931 1065334473
0 4608 88244 -256643275878 719957368 858606637
0 63577 61150 -709420603776 226182438 471777192
0 9447 45793 -888585617774 240091200 786422931
0 22919 34460 -287127301718 800646922 473599827
0 43425 30387 -231526557524 130919927 89162...

output:

0
0
0
1
0
0
1
0
0
0
0
0
1
0
0
0
0
1
1
0
0
1
0
1
1
1
0
1
1
1
0
1
1
1
0
0
1
0
0
0
0
1
1
1
0
1
1
1
1
0
0
1
0
0
1
0
1
1
0
1
1
1
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
1
1
0
1
0
0
1
1
0
0
1
0
1
0
0
0
1
0
1
0
0
1
1
1
1
1
1
0
1
1
0
0
1
1
0
0
1
0
0
0
1
1
1
1
0
0
0
1
1
0
0
1
0
0
0
0
1
0
0
1
1
0
1
1
0
1
1
0
0
...

result:

ok 500000 numbers

Extra Test:

score: 0
Extra Test Passed