QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#785343 | #9633. 轮盘赌游戏 | zhouhuanyi | 100 ✓ | 1609ms | 653320kb | C++17 | 7.9kb | 2024-11-26 17:36:49 | 2024-11-26 17:36:50 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<map>
#include<algorithm>
#include<random>
#include<vector>
#define N 400000
#define W 5000000
#define K 35000000
#define M 5000
#define Z 1048575
#define mod 998244353
using namespace std;
mt19937 RAND(random_device{}());
const long long inf=(long long)(1e18);
long long read()
{
char c=0;
long long sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int fast_pow(int a,int b)
{
int res=1,mul=a;
while (b)
{
if (b&1) res=1ll*res*mul%mod;
mul=1ll*mul*mul%mod,b>>=1;
}
return res;
}
int MD(int x)
{
return x>=mod?x-mod:x;
}
int MD2(int x)
{
return x<0?x+mod:x;
}
void Adder(int &x,int d)
{
x=x+d>=mod?x+d-mod:x+d;
return;
}
void Adder2(int &x,int d)
{
x=x+d<0?x+d+mod:x+d;
return;
}
long long n,ds,dw;
long long gcd(long long a,long long b)
{
if (!b) return a;
else return gcd(b,a%b);
}
int m,q,t,rest,lengz,ans[N+1],sz[N+1],ls[N+1],rs[N+1],Y[N+1],p[N+1],rt[M+1],srt[M+1],rd[Z+1],rd2[Z+1],rd3[Z+1];
long long X[N+1];
bool used[N+1];
vector<int>v[N+1];
vector<int>sv[N+1];
vector<long long>st[N+1];
map<long long,int>P;
struct rds
{
int mul,wl,wr,res,res2;
};
rds c,zero,delta[N+1];
rds operator + (rds a,rds b)
{
return (rds){1ll*a.mul*b.mul%mod,(a.wl+1ll*a.mul*b.wl)%mod,(b.wr+1ll*b.mul*a.wr)%mod,(a.res+b.res+1ll*a.wr*b.wl)%mod,(1ull*a.res2*b.mul+1ull*b.res2*a.mul+1ull*MD2(a.wl+1-a.mul)*MD2(b.wr+1-b.mul))%mod};
}
long long calc(rds a)
{
int res=MD(a.res+a.res2);
Adder2(res,-a.mul),Adder2(res,-MD2(a.wl-a.mul)),Adder2(res,-MD2(a.wr-a.mul)),Adder2(res,-1);
res=1ll*res*fast_pow(MD2(1-a.mul),mod-2)%mod;
return res;
}
struct WBLT
{
struct node
{
int ls,rs;
long long sz;
rds data;
};
node tree[W+1];
int length;
int new_node(int d)
{
++length,tree[length]=(node){0,0,1,(rds){d,d,d,MD(d+1),1}};
return length;
}
void push_up(int k)
{
tree[k].sz=tree[tree[k].ls].sz+tree[tree[k].rs].sz,tree[k].data=tree[tree[k].ls].data+tree[tree[k].rs].data;
return;
}
rds query(long long k,long long L,long long R,long long l,long long r)
{
if (L==l&&R==r) return tree[k].data;
long long mid=L+tree[tree[k].ls].sz-1;
if (r<=mid) return query(tree[k].ls,L,mid,l,r);
else if (l>=mid+1) return query(tree[k].rs,mid+1,R,l,r);
else return query(tree[k].ls,L,mid,l,mid)+query(tree[k].rs,mid+1,R,mid+1,r);
}
};
WBLT T;
struct seg
{
struct node
{
int ls,rs;
rds data;
};
node tree[K+1];
int length;
void push_up(int k)
{
tree[k].data=tree[tree[k].ls].data+tree[tree[k].rs].data;
return;
}
int build(int l,int r)
{
int nw=++length;
if (l==r)
{
tree[nw].data=delta[l];
return nw;
}
int mid=(l+r)>>1;
tree[nw].ls=build(l,mid),tree[nw].rs=build(mid+1,r),push_up(nw);
return nw;
}
int add(int k,int L,int R,int x,rds d)
{
int nw=++length;
tree[nw]=tree[k];
if (L==R)
{
tree[nw].data=d;
return nw;
}
int mid=(L+R)>>1;
if (x<=mid) tree[nw].ls=add(tree[nw].ls,L,mid,x,d);
else tree[nw].rs=add(tree[nw].rs,mid+1,R,x,d);
push_up(nw);
return nw;
}
};
seg T2;
struct reads
{
int d[M+1],res;
};
reads e,d1,d2,d3;
int merge(int x,int y)
{
if (!x||!y) return x^y;
int nw=++T.length;
T.tree[nw].ls=x,T.tree[nw].rs=y,T.push_up(nw);
return nw;
}
reads operator * (reads a,reads b)
{
for (int i=0;i<m;++i) a.d[i]=merge(a.d[i],b.d[(i+a.res)%m]);
a.res=(a.res+b.res)%m;
return a;
}
reads fast_pow(reads a,long long b)
{
reads res=e,mul=a;
while (b)
{
if (b&1) res=res*mul;
if (b) mul=mul*mul;
b>>=1;
}
return res;
}
reads solve(long long x,long long a,long long b,long long c,reads d1,reads d2)
{
if (!x) return e;
if (b>=c) return fast_pow(d1,b/c)*solve(x,a,b%c,c,d1,d2);
if (a>=c) return solve(x,a%c,b,c,d1,fast_pow(d1,a/c)*d2);
long long y=((__int128)(a)*x+b)/c;
if (!y) return fast_pow(d2,x);
return fast_pow(d2,(c-b-1)/a)*d1*solve(y-1,c,(c-b-1)%a,a,d2,d1)*fast_pow(d2,x-((__int128)(c)*y-b-1)/a);
}
long long sx,sy;
void exgcd(long long a,long long b)
{
if (!b)
{
sx=1,sy=0;
return;
}
exgcd(b,a%b);
long long tx=sx-(a/b)*sy;
sx=sy,sy=tx;
return;
}
long long get_inv(long long a,long long p)
{
exgcd(a,p);
return (sx%p+p)%p;
}
struct node
{
long long num;
int data,nxt;
};
node edge[N+1],edge2[N+1];
int head[Z+1],head2[Z+1],len,len2;
void insert(long long x,int d)
{
int sx=rd[x&Z]^rd2[(x>>20)&Z]^rd3[x>>40];
edge[++len]=(node){x,d,head[sx]},head[sx]=len;
return;
}
int find(long long x)
{
int sx=rd[x&Z]^rd2[(x>>20)&Z]^rd3[x>>40];
for (int i=head[sx];i>0;i=edge[i].nxt)
if (edge[i].num==x)
return edge[i].data;
return -1;
}
void insert2(long long x,int d)
{
int sx=rd[x&Z]^rd2[(x>>20)&Z]^rd3[x>>40];
edge2[++len2]=(node){x,d,head2[sx]},head2[sx]=len2;
return;
}
int find2(long long x)
{
int sx=rd[x&Z]^rd2[(x>>20)&Z]^rd3[x>>40];
for (int i=head2[sx];i>0;i=edge2[i].nxt)
if (edge2[i].num==x)
return edge2[i].data;
return -1;
}
void change(long long x,int d)
{
int ds,pst=find2(x);
if (find(x%dw)==-1) insert(x%dw,++lengz);
ds=find(x%dw);
if (sv[ds].empty()) sv[ds].push_back(srt[(x%dw)%m]);
Adder2(rest,-calc(T2.tree[sv[ds].back()].data)),sv[ds].push_back(T2.add(sv[ds].back(),0,st[(x%dw)%m].size()-1,pst,(rds){d,d,d,MD(d+1),1})),Adder(rest,calc(T2.tree[sv[ds].back()].data));
return;
}
void undo(long long x)
{
int ds=find(x%dw);
Adder2(rest,-calc(T2.tree[sv[ds].back()].data)),sv[ds].pop_back(),Adder(rest,calc(T2.tree[sv[ds].back()].data));
return;
}
void dfs(int x)
{
if (!ls[x])
{
sz[x]=1;
return;
}
dfs(ls[x]),dfs(rs[x]),sz[x]=sz[ls[x]]+sz[rs[x]];
return;
}
void dfs2(int x)
{
if (!ls[x])
{
change(X[x],Y[x]),ans[x]=rest,v[x].push_back(x);
return;
}
if (sz[ls[x]]>sz[rs[x]])
{
dfs2(rs[x]);
for (int i=0;i<v[rs[x]].size();++i) undo(X[v[rs[x]][i]]);
dfs2(ls[x]);
for (int i=0;i<v[rs[x]].size();++i) change(X[v[rs[x]][i]],Y[v[rs[x]][i]]);
ans[x]=rest,swap(v[x],v[ls[x]]);
for (int i=0;i<v[rs[x]].size();++i) v[x].push_back(v[rs[x]][i]);
}
else
{
dfs2(ls[x]);
for (int i=0;i<v[ls[x]].size();++i) undo(X[v[ls[x]][i]]);
dfs2(rs[x]);
for (int i=0;i<v[ls[x]].size();++i) change(X[v[ls[x]][i]],Y[v[ls[x]][i]]);
ans[x]=rest,swap(v[x],v[rs[x]]);
for (int i=0;i<v[ls[x]].size();++i) v[x].push_back(v[ls[x]][i]);
}
return;
}
int main()
{
int a,b,pst;
long long x,ps;
reads rts;
for (int i=0;i<=Z;++i) rd[i]=RAND()&Z,rd2[i]=RAND()&Z,rd3[i]=RAND()&Z;
n=read(),m=read(),ds=read(),q=read(),t=read();
for (int i=0;i<m;++i) p[i]=read(),T.new_node(p[i]);
d1.res=(m-n%m)%m,d2.res=ds%m,d3.res=(n-ds)%m;
for (int i=0;i<m;++i) d2.d[i]=(i+ds)%m+1;
dw=gcd(n,ds),rts=d3*solve(n/dw,ds,n-ds,n,d1,d2);
for (int i=0;i<m;++i) rt[i]=rts.d[i],Adder(rest,1ll*calc(T.tree[rt[i]].data)*(((dw+m-1-i)/m)%mod)%mod);
ans[0]=rest;
for (int i=1;i<=q;++i)
{
X[i]=read(),Y[i]=read(),ps=(__int128)(X[i]/dw)*get_inv(ds/dw,n/dw)%(n/dw),st[(X[i]%dw)%m].push_back(ps);
if (ps) st[(X[i]%dw)%m].push_back(ps-1);
}
for (int i=0;i<m;++i)
if (!st[i].empty())
{
st[i].push_back(T.tree[rt[i]].sz-1),sort(st[i].begin(),st[i].end()),st[i].resize(unique(st[i].begin(),st[i].end())-st[i].begin()),ps=-1;
for (int j=0;j<st[i].size();++j) delta[j]=T.query(rt[i],0,T.tree[rt[i]].sz-1,ps+1,st[i][j]),ps=st[i][j];
srt[i]=T2.build(0,st[i].size()-1);
}
for (int i=1;i<=q;++i)
{
x=X[i],ps=(__int128)(x/dw)*get_inv(ds/dw,n/dw)%(n/dw);
pst=lower_bound(st[(x%dw)%m].begin(),st[(x%dw)%m].end(),ps)-st[(x%dw)%m].begin(),insert2(x,pst);
}
for (int i=1;i<=t;++i) a=read(),b=read(),ls[q+i]=a,rs[q+i]=b;
for (int i=1;i<=q+t;++i)
{
if (ls[i]) used[ls[i]]=1;
if (rs[i]) used[rs[i]]=1;
}
for (int i=1;i<=q+t;++i)
if (!used[i])
{
dfs(i),dfs2(i);
for (int j=0;j<v[i].size();++j) undo(X[v[i][j]]);
}
for (int i=0;i<=q+t;++i) printf("%d\n",ans[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 22ms
memory: 76772kb
input:
851 5000 361 851 850 562391496 297295230 133155069 23646451 281403231 908996455 508404744 523068962 730052620 497638519 452330980 95204096 834100564 660556911 942051151 908660973 663842872 210992115 701314986 855804745 739054153 631209838 753323725 842223873 2032098 495149101 88559726 763775769 7618...
output:
732255452 720376951 184323732 965424167 81885236 217818248 915007060 859470597 873059725 640900479 49028913 791771459 906528319 46653823 291234709 297686919 700289785 759307641 638187788 988048572 222111156 700569068 941724353 555016464 855391452 727257779 464334677 650489407 396744652 528993028 835...
result:
ok 1702 lines
Test #2:
score: 10
Accepted
time: 16ms
memory: 81336kb
input:
904 5000 527 904 903 121143047 166285751 24056756 561602651 450410141 628584370 665219187 854838418 178253540 865778375 231189062 477601890 332949629 166911260 953834705 880630449 156640674 968283002 943597703 947373350 747053163 381163216 238128317 71633316 116759880 449075610 776300739 596461381 6...
output:
300820758 741093367 936216934 13356994 226976925 17238882 376787753 718087088 591173797 541544017 852751732 227600682 410121400 910975751 349906760 231339543 260525137 791707897 562152892 372610946 801971909 228376909 309112352 372763444 779126878 472182210 477209686 988304907 282569379 513353598 72...
result:
ok 1808 lines
Test #3:
score: 10
Accepted
time: 27ms
memory: 81508kb
input:
1000 5000 709 1000 999 309012044 934793154 23203265 253779972 940154706 63831785 634867416 904248621 248454135 394524817 546738413 181281462 816734836 507880028 863571472 46785250 712145755 224118936 709669751 251683893 461491496 514303755 149299545 2360317 407068942 161504316 383929704 621498269 91...
output:
128835200 430604116 59761712 863159482 29699623 909028510 472845742 688822546 517905101 956413934 174561806 721544837 816163926 105304428 395318281 85268014 611945806 66461889 132981887 926981603 287261882 920774399 502082320 26839708 546076800 467860057 447428188 755448276 121461519 28908840 363212...
result:
ok 2000 lines
Test #4:
score: 10
Accepted
time: 18ms
memory: 81040kb
input:
1000 5000 757 1000 999 259019298 123008007 786928414 192492877 227554519 210639898 590405706 888289296 814080469 140302522 986047983 291748570 936237029 279876955 834492571 359417817 957899062 59678966 140293278 323572901 591173259 22242840 995328276 847845816 994500116 956787921 673916631 653289096...
output:
239227475 17397950 550356456 850353558 704833672 416532312 872192769 965440251 484908183 171685079 124766086 311904363 303928481 514747121 207508157 244070004 354260502 509938078 489724657 401018629 913245970 212819819 988077318 875281909 378490036 787257149 952661149 492933366 647401227 644316817 2...
result:
ok 2000 lines
Test #5:
score: 10
Accepted
time: 21ms
memory: 73612kb
input:
1000 5000 997 1000 999 678558257 422157827 849132446 302692899 820682437 221000382 506199295 740413371 919225940 310273606 144099086 732204114 438375855 95176368 878857558 512808702 879059325 732066022 426746548 18941660 461623764 137397388 321716024 400514347 20435456 760726719 947853524 150600778 ...
output:
571824957 540725061 597628721 120706795 793296023 458260478 180335887 493569672 260060048 361022538 604018090 483981821 624679017 621465356 696718813 416886120 493806827 458860633 419994239 432998695 584064811 833941156 371039228 38897821 509720452 854060324 688357323 811006040 175340873 815372546 6...
result:
ok 2000 lines
Subtask #2:
score: 15
Accepted
Test #6:
score: 15
Accepted
time: 990ms
memory: 470092kb
input:
809731 5000 259722 100000 99999 463513923 424784861 273728173 388698128 366230745 656390296 91931885 414046637 540945961 263769532 761480653 167327505 831936859 491166887 577832753 135496691 925357980 669881180 177103065 874203946 705048224 990781865 98730868 255425653 995293048 767757975 481914668 ...
output:
883355444 37891658 696621319 575605597 430762088 898643807 374358226 805595583 85016769 264587169 400690867 711410004 637471967 579527106 919228676 448099215 889079348 398796385 83961765 399406704 499557594 475591388 635357054 314263825 160816193 314939910 879057520 947169871 682710351 236716826 258...
result:
ok 200000 lines
Test #7:
score: 15
Accepted
time: 1283ms
memory: 590032kb
input:
700248 5000 500383 100000 99999 778149423 5641488 488502344 634206068 373799845 292224715 403069880 502072465 795754347 849454113 942557274 127108350 830284170 163719287 464313615 353019568 812762932 845037003 948768810 245651161 773031790 741050114 23850823 237765271 320882637 307439766 310552802 7...
output:
507125614 716820121 418824846 974254657 459679359 29470277 58451722 174505984 301636676 460175306 898379808 971231491 23772224 927398459 65505808 658667587 280719414 487326261 674418444 760232956 42188290 442152178 954446364 177983949 474015682 218958977 208822432 741133373 261827718 817440436 57958...
result:
ok 200000 lines
Test #8:
score: 15
Accepted
time: 559ms
memory: 271656kb
input:
1000000 5000 796423 100000 99999 980130431 331826001 191577028 569389578 768919334 837886531 644574559 196226484 154073059 697290638 195310509 479667815 679214749 551777585 650941333 846558983 446137433 680681237 763050824 924711280 505867090 557841451 65598074 154624416 576206819 392054753 31370304...
output:
725203837 947839971 231559303 871284847 786813388 225438682 483902135 429994144 905378982 803696310 421825285 738404079 339963841 45917971 409139134 720396520 742062843 513885834 567902976 284998846 867334946 278450108 877569337 439270607 3326249 223685716 413185324 84723956 286803560 235195100 6521...
result:
ok 200000 lines
Test #9:
score: 15
Accepted
time: 1194ms
memory: 587396kb
input:
1000000 5000 889301 100000 99999 128294133 618804455 214187457 613014966 324333893 124031071 121569660 385626452 150794670 577794942 230989381 778339696 293478436 674606939 454031164 973003604 671994244 834889615 527437199 62573135 709437069 661524052 483297063 507847319 155020033 837013797 19600782...
output:
92843955 661290560 610407184 615583573 691076760 738088273 877130602 549985474 586214470 121318643 94935376 753764692 611412653 713228370 272765833 976316307 815539248 349703901 303041697 854413954 278632835 758479973 265132462 642520490 806702309 502330224 906778377 945366083 704257064 260085823 26...
result:
ok 200000 lines
Test #10:
score: 15
Accepted
time: 984ms
memory: 474584kb
input:
1000000 5000 557013 100000 99999 543596923 841186148 328119683 265552198 755019953 598782249 374871433 719870368 883819159 156752820 766005962 965638384 312784249 170846024 197259679 310948345 512524295 229097193 574211156 756421 898279532 308229228 191079380 555781603 951276236 979762447 242033640 ...
output:
42474015 137481109 902735119 801980720 700780647 573822662 669224163 391632309 587708462 683634016 57160558 132382562 544713387 833510585 499220358 914359996 297402212 597441093 165147453 727642158 982518884 78449875 536947975 664497456 118648487 934608673 979783029 150953577 635132325 741451383 974...
result:
ok 200000 lines
Subtask #3:
score: 30
Accepted
Test #11:
score: 30
Accepted
time: 1161ms
memory: 458628kb
input:
6978606644777960 5000 1 100000 99999 833048425 51040378 151570173 677750389 726993243 418098444 866063532 566770994 894477023 461650459 269177527 280641840 220743333 198879702 661221795 125224622 594572884 809239438 498948560 725776275 133844230 107432317 711720580 515970129 464813790 646982506 5532...
output:
124855168 787411905 364594656 876665127 979493464 879256633 20276424 793398235 637010628 306277099 175798250 213814707 787285368 933483788 440649556 882745912 770636264 521601831 988733397 585508883 887468363 197755773 619814858 416260030 703385628 510083804 646890794 604633666 20692517 221576043 45...
result:
ok 200000 lines
Test #12:
score: 30
Accepted
time: 1437ms
memory: 575980kb
input:
9711807334465217 5000 1 100000 99999 299434878 937505960 981986538 492762594 66988926 64559715 475779500 587462746 573580162 740282138 48107125 508389836 305173603 961091671 989934198 478692896 54771021 13517956 314098006 859555077 633623820 375385222 309737104 181594467 641342432 954324170 57455962...
output:
37402075 400200945 484219361 664488729 992154680 193192852 738184678 231403099 158407319 982444282 612358620 920246514 476562244 463376824 502482563 650909344 95165697 761451511 75734473 34580873 476812566 505243008 54954184 85757241 485825548 455550008 92455124 135032757 583806519 662050219 4606033...
result:
ok 200000 lines
Test #13:
score: 30
Accepted
time: 684ms
memory: 257940kb
input:
10000000000000000 5000 1 100000 99999 920750207 871724411 309026926 833185786 796742078 390409979 538993364 758004210 5928814 470089103 292658321 853059459 238926006 953061708 152012759 353349549 826733207 680874685 852704259 655285531 812673885 929009123 882286590 22886915 39922066 64712039 6326989...
output:
690938699 396273999 571250609 363304083 769585913 331448036 497756949 927110993 690828760 31487613 899876051 709507559 917961860 598540623 74918198 577663897 546575244 744244748 790813195 2438388 257477946 214137013 827744211 632652439 189217932 528309897 191787171 838346516 895502583 141616295 1511...
result:
ok 200000 lines
Test #14:
score: 30
Accepted
time: 1383ms
memory: 577392kb
input:
10000000000000000 5000 1 100000 99999 809331797 449120316 699028802 328110030 160000309 51116464 400625137 213020983 992708038 545917015 67804113 510961431 394937339 83740183 752540263 27971067 739406552 653557561 852100945 847587531 903954877 681573262 47111231 924720165 172967769 167968136 9566757...
output:
990305292 830365869 449405184 501199300 343912159 154035033 11352114 409088429 194258447 161678556 838143281 848312406 773315679 568234858 992946183 856818010 935493477 291837756 499446969 430016052 492938078 339702372 509680735 442056942 823656125 212889188 572394003 243467807 423605699 569757896 4...
result:
ok 200000 lines
Test #15:
score: 30
Accepted
time: 1161ms
memory: 467388kb
input:
10000000000000000 5000 1 100000 99999 180631234 6672351 379072456 929668228 598353021 366766807 617368430 552966300 898935603 449782485 344552431 532077185 526882086 524456963 64322871 284661834 621726399 732720093 470566290 523517055 585129700 734569962 447707812 908994457 306968905 22595239 279597...
output:
810388783 358815862 206845214 287589726 278552760 711875224 812649353 449725427 300864767 156617722 356779611 218339911 757851892 749918894 942486334 468633218 853927557 678437562 221088959 776417329 46101148 602191260 869721202 510183641 400290515 966055269 678074159 190045091 487334613 650064981 5...
result:
ok 200000 lines
Subtask #4:
score: 20
Accepted
Test #16:
score: 20
Accepted
time: 37ms
memory: 125404kb
input:
6948836324389626 5000 6496512310216067 0 0 100833165 402440440 831537787 85770452 205780855 257576293 736144497 273314125 762251139 87182252 244149285 682859227 421232261 471972396 679336761 942776614 791031154 265657083 113634147 969949444 290733932 407012180 332034867 203099168 394273399 167096369...
output:
788029930
result:
ok single line: '788029930'
Test #17:
score: 20
Accepted
time: 51ms
memory: 139180kb
input:
6109528790701312 5000 3945330762444989 0 0 806890518 464021774 299047113 613746083 981069809 374677869 84705503 583250358 699265259 189925233 857063079 804086416 89127755 318089925 9701667 861042474 512359940 397931892 612938563 423912391 321156344 744863728 666646617 879091997 976414443 54212712 93...
output:
226116857
result:
ok single line: '226116857'
Test #18:
score: 20
Accepted
time: 28ms
memory: 129472kb
input:
10000000000000000 5000 630003173088603 0 0 578395063 125641284 163389 148842811 372427902 369006320 815458216 258359730 143409141 807410143 139457482 139750830 218887486 553110086 91348957 193367978 642691286 373912863 959242284 62076 868797890 691634263 315199349 410106004 882112815 238282035 92950...
output:
774147387
result:
ok single line: '774147387'
Test #19:
score: 20
Accepted
time: 38ms
memory: 135388kb
input:
10000000000000000 5000 7966226205281781 0 0 525636119 37465429 433677501 45498406 672741312 137476522 783863146 1028591 844170928 454686313 647807581 896489632 989081980 823039723 894425830 365398071 345628940 421235127 476537647 988734595 502135096 383109311 993948921 343727532 824425519 576016986 ...
output:
127734358
result:
ok single line: '127734358'
Test #20:
score: 20
Accepted
time: 32ms
memory: 129760kb
input:
10000000000000000 5000 8510948317408143 0 0 162844298 134461374 397778957 593963055 145008816 622368382 441070633 62898002 41499250 27559323 785112604 586984257 864866251 959130132 672087443 241147794 191369645 503684543 620458671 856012880 560326413 637060747 850881547 472301833 857048764 301408837...
output:
995865971
result:
ok single line: '995865971'
Subtask #5:
score: 25
Accepted
Test #21:
score: 25
Accepted
time: 1340ms
memory: 535048kb
input:
5030665880174026 5000 3895861612233773 100000 99999 124821508 874253112 249425247 373425006 201991447 679876006 317765521 927948210 271641389 612286223 350979936 852686781 426019476 869812500 215269788 685457089 208108738 184211360 807037629 865352527 464074106 942234401 181979669 959577146 44257946...
output:
221555166 774146239 313049946 675120652 412031766 754688845 486397054 738223036 702620398 305716915 434391586 883035133 281189823 15075683 875100162 364572680 132764130 23886800 210165041 97689839 418039886 725163079 807991978 660312101 248203437 437366183 774378119 63317603 946576078 339426206 8901...
result:
ok 200000 lines
Test #22:
score: 25
Accepted
time: 1584ms
memory: 653320kb
input:
7273817803611032 5000 5870458430374149 100000 99999 829764309 928929646 874212032 222045834 175400420 187923106 50871746 345488338 849092357 272816644 13358935 469764009 281893307 555825160 165511570 616248068 872594042 247777776 755946484 260625005 79224439 83551130 395687678 246938949 816386915 40...
output:
674450394 771149695 567658102 824882421 633820179 405241917 984917277 347178436 971162927 217091393 68351083 527868742 948534898 386428437 508527036 174145060 767612049 201924189 591137825 224834429 988076976 131077988 590815955 125269968 704143243 911791811 965929614 164407367 624836379 557208265 7...
result:
ok 200000 lines
Test #23:
score: 25
Accepted
time: 854ms
memory: 322876kb
input:
10000000000000000 5000 3012108598780103 100000 99999 180451752 716031363 752682814 128416322 53734360 31030836 734140665 684300357 898068050 213612977 857452870 245078232 677032182 896994269 791711214 722609190 925562856 442979224 686690991 806923969 633607492 509445429 495237629 260472665 65797407 ...
output:
572366172 430147237 623991067 467211846 515159960 372891718 977809044 416806024 516584779 542440737 368223198 194704089 11743537 53688221 656378098 245512734 453607119 990841390 728350717 158084436 531600728 917429494 494901352 455596637 205413629 117636638 60378381 716119376 520034926 152202878 515...
result:
ok 200000 lines
Test #24:
score: 25
Accepted
time: 1609ms
memory: 643584kb
input:
10000000000000000 5000 6733489657765231 100000 99999 205909404 936000307 243919124 697386960 202026993 482260230 987443864 416895479 393740129 725976937 775126172 796479217 625953966 134328763 505566122 55993885 556554496 493587432 371224416 84604903 540797202 22827101 825613960 681773161 306828268 ...
output:
337155521 824803398 144016408 875017910 374820466 32133825 24161606 362480635 715678062 694922435 290194593 101109654 646431953 936605669 362588528 391212158 359122835 55196671 566032864 346562231 951110671 249959092 820240651 853363707 328961422 780459787 724437526 879180648 453312333 202570131 812...
result:
ok 200000 lines
Test #25:
score: 25
Accepted
time: 1318ms
memory: 525488kb
input:
10000000000000000 5000 7045687302569637 100000 99999 730070713 336061217 700211315 475295054 691705696 117223105 779032923 51890217 429701434 238392396 519118102 51307970 144992310 502579202 301823546 302397240 500032210 500029349 483754969 390546719 746418637 12433635 271777715 174727257 327558769 ...
output:
227618565 693538842 286168685 710658625 846365813 733373640 170893973 582400087 890650772 913602209 795761677 3653638 359945782 822446754 976342406 601475693 248302022 677524473 363975577 520044555 714793493 733024089 843098879 144361831 520962734 329245142 776883921 234432325 725590633 949130194 70...
result:
ok 200000 lines