QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#580157 | #9371. Mountain Booking | Crysfly | AC ✓ | 5815ms | 134544kb | C++14 | 4.9kb | 2024-09-21 20:18:10 | 2024-09-24 18:23:49 |
Judging History
answer
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
using namespace std;
#define pb push_back
typedef pair<int,int>pii;
#define fi first
#define se second
#define mkp make_pair
typedef vector<int>vi;
#define inf 0x3f3f3f3f
#define maxn 1000005
int read(){
char c=getchar();int x=0;
for(;!isdigit(c);c=getchar());
for(;isdigit(c);c=getchar())x=x*10+(c&15);
return x;
}
int n,m,m1,m2;
vector<pii>qs[maxn];
vi per[maxn];
ll res[maxn];
#define ls(p) ch[p][0]
#define rs(p) ch[p][1]
int ch[maxn][2],fa[maxn],w[maxn],mx[maxn];
bool rev[maxn];
void up(int p){
mx[p]=w[p];
if(ls(p))mx[p]=max(mx[p],mx[ls(p)]);
if(rs(p))mx[p]=max(mx[p],mx[rs(p)]);
}
bool chk(int p){
return rs(fa[p])==p;
}
bool nrt(int p){
return ls(fa[p])==p || rs(fa[p])==p;
}
void pr(int p){
swap(ls(p),rs(p));
rev[p]^=1;
}
void down(int p){
if(rev[p]){
if(ls(p))pr(ls(p));
if(rs(p))pr(rs(p));
rev[p]=0;
}
}
void rot(int x){
// int y=fa[x],k=chk(x),s=ch[x][!k];
// if(nrt(y)) ch[fa[y]][chk(y)]=x; fa[x]=fa[y];
// ch[y][k]=s; if(s) fa[s]=y;
// ch[x][!k]=y; fa[y]=x;
//
// up(y); return;
if(!chk(x)){
int y=fa[x];
if(nrt(y)) ch[fa[y]][chk(y)]=x; fa[x]=fa[y];
ch[y][0]=ch[x][1]; if(ch[x][1]) fa[ch[x][1]]=y;
ch[x][1]=y; fa[y]=x; up(y);
}else{
int y=fa[x];
if(nrt(y)) ch[fa[y]][chk(y)]=x; fa[x]=fa[y];
ch[y][1]=ch[x][0]; if(ch[x][0]) fa[ch[x][0]]=y;
ch[x][0]=y; fa[y]=x; up(y);
}
}
void downall(int x){
if(nrt(x))downall(fa[x]);
down(x);
}
void splay(int x){
downall(x);
while(nrt(x)){
int y=fa[x];
if(nrt(y)) rot(chk(x)==chk(y)?y:x);
rot(x);
}up(x);
}
void acc(int x){
// cout<<"acc "<<x<<"\n";
for(int y=0;x;x=fa[y=x]){
splay(x);
rs(x)=y;
up(x);
}
}
void mkrt(int x){
acc(x),splay(x),pr(x);
}
void link(int x,int y){
// cerr<<"link "<<x<<" "<<y<<"\n";
mkrt(x);
fa[x]=y;
}
void cut(int x,int y){
mkrt(x),acc(y),splay(y);
fa[ls(y)]=0;
ls(y)=0; up(y);
}
bool bru[maxn];
int eu[maxn],ev[maxn],ew[maxn],in[maxn],dl[maxn],ids[maxn],tot;
int eu2[maxn],ev2[maxn],ew2[maxn],to[maxn];
void cute(int id){
in[to[id]]=0;
cut(id+n,eu[id]);
cut(id+n,ev[id]);
}
void linke(int id){
// cerr<<"lnk "<<id<<"\n";
in[to[id]]=1;
link(id+n,eu[id]);
link(id+n,ev[id]);
}
int ff[maxn];
int gf(int x){
while(x!=ff[x])x=ff[x]=ff[ff[x]];
return x;
}
int L[maxn],R[maxn],cnt;
int cntb[maxn];
ll ans[maxn],ww[maxn];
void dfs0(int u,ll now){
if(u>n){
dfs0(L[u],now+cntb[R[u]]*ww[u]);
dfs0(R[u],now+cntb[L[u]]*ww[u]);
}else{
ans[u]=now;
}
}
bool flag;
int *Ls[maxn],*Rs[maxn];
void solve(int id){
For(i,1,n)ff[i]=i,cntb[i]=0,ans[i]=0;
for(int x:per[id])cntb[x]++;
cnt=n;
For(i,1,tot){
if(!in[i])continue;
int u=eu2[i],v=ev2[i];
u=gf(u),v=gf(v);
++cnt;
L[cnt]=u,R[cnt]=v;
ww[cnt]=ew2[i];
cntb[cnt]=cntb[u]+cntb[v];
ff[u]=ff[v]=ff[cnt]=cnt;
}
//if(flag)return;
ans[cnt]=0;
Rep(u,cnt,n+1){
ans[L[u]]=ans[u]+cntb[R[u]]*ww[u];
ans[R[u]]=ans[u]+cntb[L[u]]*ww[u];
}
for(auto it:qs[id]) res[it.se]=ans[it.fi];
}
pair<ll,int> wei[maxn];
bool vs[maxn];
void work()
{
n=read(),m=read(),m1=read(),m2=read();
For(i,1,n-1){
eu[i]=read(),ev[i]=read(),ew[i]=read();
w[i+n]=mx[i+n]=ew[i];
}
For(i,1,m){
dl[i+n-1]=read(),eu[i+n-1]=read(),ev[i+n-1]=read(),ew[i+n-1]=read();
w[i+n+n-1]=mx[i+n+n-1]=ew[i+n-1];
}
For(i,1,m1){
int x=read(),y=read();
per[x].pb(y);
}
For(i,1,m2){
int x=read(),y=read();
qs[x].pb(mkp(y,i));
}
tot=m+n-1;
For(i,1,tot) ids[i]=i;
sort(ids+1,ids+tot+1,[&](int x,int y){
return ew[x]<ew[y];
});
For(i,1,tot){
eu2[i]=eu[ids[i]];
ev2[i]=ev[ids[i]];
ew2[i]=ew[ids[i]];
to[ids[i]]=i;
}
For(i,1,n-1) linke(i);
cerr<<"QSQ\n";
flag=(eu[1]==1785);
For(i,1,m) wei[i]=mkp(1ll*qs[i].size()*per[i].size(),i);
sort(wei+1,wei+m+1);
ll cur=0;
int V=11000000;
For(i,1,m){
cur+=wei[i].fi;
if(cur<=V) vs[wei[i].se]=1;
else break;
}
int ss=0;
For(i,1,m){
// cout<<"i: "<<i<<"\n";
cute(dl[i+n-1]);
linke(i+n-1);
// continue;
if( vs[i] ){
// if(flag) continue;
bru[i]=1;
for(auto it:qs[i]){
int u=it.fi,id=it.se;
mkrt(u);
for(int v:per[i]){
acc(v);splay(v);
res[id]+=mx[v];
}
}
}
else {
++ss;
// if(flag) continue;
solve(i);
}
}
cerr<<"ss "<<ss<<"\n";
// if(flag) cout<<"ss "<<ss<<"\n";
For(i,1,m2) printf("%lld\n",res[i]);
}
signed main(){
// freopen("data.in","r",stdin);
// freopen("my.out","w",stdout);
int T=1;
while(T--)work();
return 0;
}
/*
5 3 6 1
1 2 9
1 3 4
1 4 6
4 5 2
3 3 5 3
2 1 5 5
5 3 4 8
1 3
2 1
3 3
2 4
1 5
2 4
1 1
0 6 1
0 6 2
0 7 1
0 7 3
0 8 1
0 8 4
0 9 4
0 9 5
1 8 1
1 8 4
*/
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 8ms
memory: 80784kb
input:
5 3 6 6 1 2 9 1 3 4 1 4 6 4 5 2 3 3 5 3 2 1 5 5 5 3 4 8 1 3 2 1 3 3 2 4 1 5 2 4 1 1 1 3 2 5 2 3 3 1 3 3
output:
8 3 9 11 8 0
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 681ms
memory: 122656kb
input:
100000 200000 200000 200000 35656 70681 897539746 21671 70681 651391385 21671 10081 522257791 17226 10081 798135326 98500 17226 310898100 32577 98500 289079819 16171 32577 111049018 57000 16171 543797391 57000 40721 646112759 40721 74677 753482011 98995 74677 575786599 94060 98995 373172622 27709 94...
output:
24913955399233 24805856666249 24972973736013 24942936981415 24806465110654 24996275118120 24892315334772 24847353124362 24755276690631 24959171319638 24808479222077 25079856238089 24856860765237 24911355864057 24365576128556 24880154548116 24901786584898 24846522034911 24899671247471 24887363835352 ...
result:
ok 200000 lines
Test #3:
score: 0
Accepted
time: 819ms
memory: 125792kb
input:
100000 200000 200000 200000 4231 71205 29560967 71205 31885 336130168 31885 44154 255664865 44154 86683 751229458 35406 86683 218737705 43284 35406 897614303 43284 29758 59995010 29758 5459 153942428 42349 5459 686685454 42462 42349 247761205 42462 90672 304800452 55408 90672 395684991 26049 55408 2...
output:
3990360411758 3891453097499 3932280911311 4007720176367 3842817597461 3894937810942 4053516472572 3987255615257 3895896929439 3980284927479 3895301448669 3955822722807 3970923956912 3934972512071 3966317011723 3973081861552 3931113275743 3921157522456 4002202092260 4098061701129 4072263776877 395084...
result:
ok 200000 lines
Test #4:
score: 0
Accepted
time: 4859ms
memory: 122268kb
input:
100000 200000 200000 200000 80788 88207 362241330 88207 9928 36350815 92883 9928 745497294 43678 92883 460988191 43678 80665 137626774 80665 25044 144782356 25044 58023 656904063 54748 58023 509743715 54748 7805 12283920 55340 7805 89694383 8172 55340 370716874 47267 8172 22653258 47267 74816 585261...
output:
810539334596 881200712183 910949742211 886843065064 868412638383 900981122899 857707348699 843614298857 930456150154 832454041082 820959715680 840705255900 881081847392 844771306385 865966019428 802996246602 837640169725 885666637614 863720395931 879175626677 850901610607 879733184073 905111675353 8...
result:
ok 200000 lines
Test #5:
score: 0
Accepted
time: 5300ms
memory: 124824kb
input:
100000 200000 200000 200000 28147 98826 768663517 98826 79937 810313286 34098 79937 161522364 34098 98168 170779693 98168 43025 56515843 43025 31144 465692233 31144 19460 253878651 19460 54766 865610537 1036 54766 264173329 47631 1036 5336617 47631 90859 436666065 32287 90859 723396117 93932 32287 9...
output:
413108947580 362252308276 381032159397 422930385113 340736268884 369216713214 374843144901 416084544625 424483378045 383774201991 406444478776 409456025991 413381347142 387316849135 405429983642 393302173053 409406194384 397848669311 394823736321 371013390460 410885568688 386163833103 343276007901 4...
result:
ok 200000 lines
Test #6:
score: 0
Accepted
time: 5815ms
memory: 126436kb
input:
100000 200000 200000 200000 1785 8203 494262552 1785 65990 794798654 65990 63656 478871600 1245 63656 414082324 1245 63476 45499147 16163 63476 753349609 16163 23015 532140998 81429 23015 119888752 7431 81429 52823846 95654 7431 657748169 95654 56941 99763495 56941 71217 45198395 71217 53594 8087944...
output:
100947046498 102524893089 92517806271 81616949155 110748760059 106580824246 108859838733 101827824629 103849812494 102939802143 113714156477 108271882351 113307627405 110487752662 104526004877 85331171177 95603066897 86930012643 101533270154 119656435064 94581680386 97527113559 88760227647 934796570...
result:
ok 200000 lines
Test #7:
score: 0
Accepted
time: 1472ms
memory: 111316kb
input:
100000 200000 200000 200000 79490 47719 311339498 79490 80868 68638605 5364 80868 690426835 18317 5364 934187098 18317 5183 396068624 5183 78710 587185406 25319 78710 717681997 90112 25319 54363893 49538 90112 146989706 49538 61585 783914633 61585 18723 233053878 52681 18723 666819327 92743 52681 35...
output:
16975633237 15840577802 17974239102 20876700825 19945217236 17989725367 19872699015 20994066177 28922442001 20931851223 47731252860 21935393365 9978459033 23900735079 16946370480 20968831449 20964499413 15989377419 17913210662 21649322534 19933364866 18887961745 26850352692 27832738018 18897213351 1...
result:
ok 200000 lines
Test #8:
score: 0
Accepted
time: 985ms
memory: 110076kb
input:
100000 200000 200000 200000 23397 11919 521335116 68394 11919 700485101 60563 68394 729597181 60563 60166 914093945 60166 95983 816797871 58856 95983 387834238 60733 58856 510801699 60733 65827 887283195 78239 65827 777916673 78239 85492 720592240 74914 85492 37299861 74914 62806 983241501 62806 348...
output:
1994626874 16917180802 2991738557 6985640052 1996352179 1998177564 4995538436 4982559836 4982369259 1995945326 995827741 15920639353 1993011914 4987253922 1989117048 2852312493 3993416510 3993240647 3978440443 4976490080 4977796657 7984414741 7995396002 3993503291 999973949 1999582196 1995455487 199...
result:
ok 200000 lines
Test #9:
score: 0
Accepted
time: 946ms
memory: 112524kb
input:
100000 200000 200000 200000 42534 34625 731297967 92188 42534 258589772 92188 15203 768734759 15203 35942 893968025 17879 35942 163719759 14001 17879 188450302 14001 97331 303921401 97331 85757 720169729 47073 85757 335134585 47073 11151 657237078 11151 57848 767771251 57848 22803 225954619 63631 22...
output:
0 4985296532 0 2991919868 3958893407 0 1991453188 1999152986 1991623432 1996615178 2990487263 937947023 3988528046 997816909 5979328435 997175964 1997167464 1955018631 1999800006 1980575113 1996324902 4967174836 1994588774 1991452001 2999948916 0 993870373 999136556 4995442743 1991635316 0 994763190...
result:
ok 200000 lines
Test #10:
score: 0
Accepted
time: 815ms
memory: 124000kb
input:
100000 200000 200000 200000 62382 50229 869674711 62382 40860 704358979 40860 25778 321128646 18360 25778 572215446 69804 18360 452379724 49235 69804 219827705 49235 1835 215193169 1835 69297 194100062 99836 69297 766584561 99836 28619 717624000 41131 28619 750346334 41131 34506 993938717 24559 3450...
output:
4015262665921 4034573175770 3902111578774 4030158537366 3906096572922 3956832868176 3908271213881 3962039328451 4085389405866 3930048701844 4002266301439 3872726224829 3940721099895 4007121711714 4000742648637 3947829411537 4058885680288 4026537758589 4008916458809 4000567870791 3904556785254 399346...
result:
ok 200000 lines
Test #11:
score: 0
Accepted
time: 4803ms
memory: 124284kb
input:
100000 200000 200000 200000 90725 81808 412383460 86396 81808 36426122 86396 33536 850098653 33536 85308 261881027 96831 85308 791965272 70820 96831 341353646 97261 70820 678996515 97261 10054 382853419 25233 10054 649400937 25233 49628 496234784 96220 49628 546734147 96220 97052 937329158 20640 970...
output:
804673505833 804156941490 916555405568 830764457727 861451609201 814656930266 797393957333 900467695468 844478491509 847512011054 870634892154 906382460041 833746811019 866978257872 837614093453 853642169311 838698521198 874456052189 829491253896 854843033739 891463255408 866172424497 858909555778 8...
result:
ok 200000 lines
Test #12:
score: 0
Accepted
time: 5196ms
memory: 132336kb
input:
100000 200000 200000 200000 25742 18903 622346310 25742 81816 594530794 81816 89473 889203463 95709 89473 241787875 13132 95709 138919928 13132 56145 142002477 16861 56145 472148985 16861 38629 215772720 3001 38629 206618849 60348 3001 432879623 60348 44566 277205538 28093 44566 180042276 28093 8220...
output:
389995556652 403467880812 376319619601 382665702284 375420501114 404202763581 400136508132 455301060601 386416702415 398393727971 376683648868 432655114771 392612276324 440598545635 401964773024 390714569652 441632385872 407619255114 409937866528 425996687895 404246495973 430977690080 403591707921 4...
result:
ok 200000 lines
Test #13:
score: 0
Accepted
time: 5784ms
memory: 125656kb
input:
100000 200000 200000 200000 50194 99810 347945345 61412 50194 579016161 385 61412 132810876 31580 385 485090506 44334 31580 127903232 44334 71630 429627085 92232 71630 750444100 92232 95783 543759992 95783 80161 995302134 80161 88989 85291175 88989 78818 14044792 78818 32994 575586378 67582 32994 34...
output:
84591183282 98364579086 121611081461 84607235506 99492165773 111518723767 109838740122 85759725370 98506977416 110330607868 90686921656 102071845716 91712422369 123337737945 87397869432 105354683460 109080003865 117799846904 91195113994 81494124764 90468960853 94846085012 92367766542 96714632913 108...
result:
ok 200000 lines
Test #14:
score: 0
Accepted
time: 1441ms
memory: 111512kb
input:
100000 200000 200000 200000 53521 32250 557908196 32250 47663 137120832 47663 43922 171948454 74807 43922 464964586 33222 74807 548632480 80068 33222 230275917 79598 80068 543563801 27329 79598 376646526 71397 27329 552520046 12201 71397 21936014 12201 63902 744548951 23733 63902 892041320 23733 248...
output:
24770423284 22776447393 20846509848 19933757930 12998648988 14953516573 13961325099 20910844965 16844006581 24960388015 12981111560 14957195801 20989816198 18932966130 22919131444 17964069812 10931161374 21970003971 20392011337 21976874987 19972678082 25889879493 18876448125 19957967858 20916826083 ...
result:
ok 200000 lines
Test #15:
score: 0
Accepted
time: 979ms
memory: 109576kb
input:
100000 200000 200000 200000 49953 97758 767903814 49953 46905 768934560 46905 87412 211118800 87412 75983 444838666 75983 33814 969296191 33814 12204 30924749 12204 23745 336683503 96935 23745 209565827 33791 96935 109737957 99585 33791 32355444 64753 99585 474987573 76576 64753 134721670 63039 7657...
output:
11990542050 1998901490 2986807074 3995432884 4992172572 2997743562 2997043515 9987607725 0 8994854871 3992130624 3972501061 3987918546 6960335227 1999563304 1995305156 4996800342 5984026161 5984121989 1997426492 5987035914 1998715778 2998074405 2989669111 1996445810 7979007557 5992982721 2983899897 ...
result:
ok 200000 lines
Test #16:
score: 0
Accepted
time: 943ms
memory: 112260kb
input:
100000 200000 200000 200000 91267 81591 977866665 63151 91267 327071999 40419 63151 250223609 40419 17437 424712746 17437 91993 316250847 87951 91993 905282636 87951 90722 129803204 90722 71075 42485129 12985 71075 740664925 30873 12985 969033051 30873 74612 205458964 29862 74612 451176612 29862 996...
output:
2998544148 2989503511 3986685023 0 4978575725 0 0 0 1979243248 5990061341 3991914212 0 1998506576 2996090830 999714159 1973475537 1996728234 2981469375 3999148930 4971573064 999876291 0 0 3953703669 0 3977906085 0 2981744877 995060420 9977740264 4968633525 1990953165 0 995550537 0 2995496529 6964657...
result:
ok 200000 lines
Test #17:
score: 0
Accepted
time: 649ms
memory: 125632kb
input:
100000 200000 200000 200000 57733 6228 947649107 14690 57733 577724868 14690 13018 626891918 83580 13018 599028161 83580 65093 965203831 69105 65093 485651108 69105 70533 133108703 70533 94245 416907095 89504 94245 283262545 19131 89504 86247820 19131 74387 751771104 74387 80094 214106698 80094 8188...
output:
24817834441834 24913004204339 24992994204085 24863010089889 24793911889240 25013938947158 25055355481490 25045351920125 24895740197201 24953813567133 24791533584102 24884030748577 25012253637098 24824203127942 24933768376119 25037930041897 25073177567109 24716127671121 24990968231513 24877541963333 ...
result:
ok 200000 lines
Test #18:
score: 0
Accepted
time: 217ms
memory: 124548kb
input:
100000 200000 200000 200000 73598 82003 847471031 13972 82003 403301983 16124 13972 62390110 28773 16124 345507827 28773 799 813720231 799 20763 212392849 20763 69274 438275308 27665 69274 125950680 94157 27665 49854751 94157 25708 201183488 25708 31829 143014216 31829 84819 697793038 53107 84819 75...
output:
25077461423368 24923441430852 24960030155088 24920049035834 24981322163983 24981664444446 24996752433031 24960618516964 24980950080928 24939870511428 25038901370612 25078267796148 24978131823771 24959032730482 24949758775420 25037485228645 24962652972580 24996947768502 24982128741979 24993889387118 ...
result:
ok 200000 lines
Test #19:
score: 0
Accepted
time: 351ms
memory: 127368kb
input:
100000 200000 200000 200000 99486 74930 180151394 74930 1231 103522630 81369 1231 478415179 81369 22012 55299329 22012 20262 732576533 91761 20262 533269958 91761 68953 35249896 68953 90951 481817503 90951 43452 375485984 3452 43452 43083898 97991 3452 208930638 97991 28257 324761306 28257 5027 5335...
output:
3963636892981 4138704779486 4120011536528 4030416026625 3995246348665 3904496130663 3995333446743 4059739236341 3904418522310 4020242498211 3904286050216 3977664567934 3982654685508 3988122219406 4019868153349 3933461083061 3904004352312 4060120562542 3972523790897 3985575030313 3981557553823 390418...
result:
ok 200000 lines
Test #20:
score: 0
Accepted
time: 4272ms
memory: 125144kb
input:
100000 200000 200000 200000 37241 48583 783032917 86133 37241 19633846 71926 86133 345135100 19617 71926 568717307 19617 36451 149658191 7002 36451 300666289 7002 31130 509722892 31130 42298 286824486 52816 42298 395723180 52816 83929 863981703 83929 92482 610324861 92482 1305 336017490 31608 1305 7...
output:
888969660629 863979670512 877912724538 918278060434 843890464365 898359285321 867655879771 847881523086 859861206564 827881587920 895686943756 868935211445 869642562698 939840269499 868915570132 840863434254 891837348896 796962336066 870762586771 867973955284 840684924380 872693455742 862776662655 9...
result:
ok 200000 lines
Test #21:
score: 0
Accepted
time: 4535ms
memory: 127664kb
input:
100000 200000 200000 200000 48197 27981 115713280 48197 73927 719854493 73927 8013 834901994 8013 56387 278476040 56387 22738 68547260 31278 22738 621576166 71887 31278 106631945 21636 71887 642691308 21636 12262 721354413 12262 18178 705914881 18178 15071 676241283 15071 24521 36727582 24521 25093 ...
output:
813513961894 408932946198 386920824939 416305736057 368733557397 377927347824 381959913874 392929524568 410969517758 435952589262 414970370416 401940592074 410953545412 384683499196 395904055269 397963905938 399964476824 392920707241 391941638936 381972002479 386974928936 406903281548 415962747543 4...
result:
ok 200000 lines
Test #22:
score: 0
Accepted
time: 4863ms
memory: 129668kb
input:
100000 200000 200000 200000 19370 82633 430690323 57329 82633 57011500 57440 57329 356753832 18297 57440 785207224 21886 18297 699591980 21886 39201 322533029 39201 64352 870069705 64352 54317 392037493 54317 87883 594019424 30620 87883 73994842 98647 30620 271997521 5088 98647 437619019 78951 5088 ...
output:
119929615788 83988113472 109803561815 100956866229 106994077262 96986305584 101983318147 81995649393 93990275838 107980954210 105985412473 110991845041 97980207049 100987318253 107987264137 97993423252 96986474321 94971474710 101986563919 117995070723 114980906946 103983158925 112953353779 849899566...
result:
ok 200000 lines
Test #23:
score: 0
Accepted
time: 1010ms
memory: 109180kb
input:
100000 200000 200000 200000 94535 72056 837145278 81638 72056 830973972 81638 61514 846553494 61514 96621 494965957 72571 96621 618448281 26418 72571 643410138 26418 869 466978758 6654 869 747904315 6654 92222 919650658 92509 92222 989669844 92509 66705 337913944 46756 66705 64620054 46756 31333 532...
output:
22998070611 17990616917 19997101051 14996328633 23963849089 16996931888 15999414285 23997252491 24996973638 22989349957 19998416625 22993534621 18992242464 15996942472 13999060117 37993421698 15993605734 11996890306 17958584749 15991235423 18993114160 26997210061 18998933581 14997103228 18998937441 ...
result:
ok 200000 lines
Test #24:
score: 0
Accepted
time: 608ms
memory: 111456kb
input:
100000 200000 200000 200000 10040 64774 850648792 39355 10040 246962667 39355 42927 434996220 42927 45227 744955383 45227 6543 467210347 85379 6543 997539749 19106 85379 456341876 94423 19106 57843328 63716 94423 782197071 63716 65315 21091880 65315 30407 806682126 11640 30407 70528903 97796 11640 8...
output:
10990706181 4999463446 2999921108 1999908820 7999793477 2999972618 3999897723 7997956133 2999992806 2999962740 2999928755 3999701338 999997907 2999813019 3999782997 6999875721 9999123018 6999530705 999957872 2999809272 3999983066 5999564049 2999398364 6999557984 6999976482 999986797 2999947667 59999...
result:
ok 200000 lines
Test #25:
score: 0
Accepted
time: 567ms
memory: 112356kb
input:
100000 200000 200000 200000 71958 45249 864185075 71958 57591 736627651 57591 54468 23504483 54468 60977 994977578 17545 60977 316005182 55449 17545 277894767 71091 55449 445672227 31468 71091 441556934 31468 3774 644710717 3774 42765 52513915 96709 42765 201708485 96709 9556 2695928 9556 49786 6920...
output:
3999972778 1999967806 2999924571 0 999777662 999991900 4999670322 0 1999980307 4999920143 0 7999151463 999974857 1999969714 1999979352 5999781616 1999994156 0 1999994156 3999656241 1999661355 999996403 6999796745 999708810 3998968693 999148798 1985611577 2999856640 4999587424 1999827948 0 0 99976341...
result:
ok 200000 lines
Test #26:
score: 0
Accepted
time: 151ms
memory: 123004kb
input:
100000 200000 200000 200000 21148 95757 1 62182 95757 2 62182 46646 3 78310 46646 4 78310 2978 5 2978 97283 6 97283 75260 7 75260 8796 8 8796 14386 9 82272 14386 10 7040 82272 11 16864 7040 12 16864 79284 13 79284 60508 14 35220 60508 15 35220 67869 16 45993 67869 17 24405 45993 18 97963 24405 19 97...
output:
6855211488 6885592507 5008591016 6859049131 4783793862 6599222285 4698730998 6281280935 5090389630 4312804113 3496382598 7275791590 6023908525 6350432936 4788022682 6695623151 4798082793 3413673901 6390396236 6607175086 4974622060 7570591716 3772747596 3569156386 3890561299 3331622836 3928957996 759...
result:
ok 200000 lines
Test #27:
score: 0
Accepted
time: 3516ms
memory: 129884kb
input:
100000 200000 200000 200000 50346 68313 1 68313 41632 2 41632 60521 3 60521 18948 4 18948 4561 5 4561 76692 6 6369 76692 7 93230 6369 8 93230 52674 9 52674 14061 10 3443 14061 11 3443 70328 12 70328 13278 13 13278 6989 14 6989 7965 15 35964 7965 16 65167 35964 17 9047 65167 18 26933 9047 19 26933 27...
output:
152333372 75541309 126602757 97588349 125985115 192740757 58828507 259644432 235413727 233864802 210953983 103077900 130512313 246307883 140857182 226821631 175926746 156713923 291453676 137405938 109498067 260047321 132561703 124706571 117377492 260951617 182483335 95454494 192862504 178004432 1645...
result:
ok 200000 lines
Test #28:
score: 0
Accepted
time: 3755ms
memory: 128008kb
input:
100000 200000 200000 200000 10033 35990 1 35990 76565 2 76565 26103 3 26103 69531 4 40714 69531 5 88465 40714 6 71188 88465 7 71188 7138 8 33606 7138 9 33606 15491 10 32480 15491 11 83723 32480 12 83723 38419 13 38419 9855 14 54372 9855 15 27569 54372 16 56501 27569 17 56501 75805 18 61791 75805 19 ...
output:
45121954 45434533 33736048 53557134 57565534 67909049 35689102 40873948 34747580 65812712 67195297 32923292 67474791 36599101 31771689 63212849 50672466 63387073 79851681 48495826 61970293 44542424 38175059 77562945 40246267 39836613 62059954 45205122 63233446 63790300 74244990 30766502 55926508 575...
result:
ok 200000 lines
Test #29:
score: 0
Accepted
time: 582ms
memory: 112672kb
input:
100000 200000 200000 200000 94114 97458 1 79238 97458 2 79238 47622 3 51161 47622 4 51161 68778 5 68778 42444 6 42444 90494 7 90494 51772 8 51772 50081 9 4905 50081 10 393 4905 11 393 33597 12 57330 33597 13 57330 65672 14 70850 65672 15 68999 70850 16 68999 74285 17 74285 17443 18 56398 17443 19 49...
output:
1252577 2264816 240960 260902 1425377 583774 1399191 564996 1665240 1569819 1587920 708249 954728 657151 1126462 503876 1435661 1294395 584687 1169391 686125 3343490 3252624 2048907 3451769 631509 1175678 1204584 660464 3769312 1516243 2645840 459969 1433673 606869 2557280 634944 786583 705768 57112...
result:
ok 200000 lines
Test #30:
score: 0
Accepted
time: 120ms
memory: 123444kb
input:
100000 200000 200000 200000 36538 86037 1 36538 80934 2 4581 80934 3 4581 57027 4 860 57027 5 95611 860 6 95611 32580 7 32580 46143 8 46143 17587 9 17587 95470 10 95470 36097 11 10301 36097 12 73903 10301 13 73903 58260 14 58260 38283 15 72640 38283 16 72640 48018 17 48018 89883 18 86659 89883 19 86...
output:
12785943390 10581067111 25863094693 29161873831 10183834051 26566540371 29178983030 9936931561 12443279069 25915948360 8482315021 9605362137 9424795655 27072537869 26790800958 25005683619 25121364766 8306170223 12685281338 28942144502 9725425679 27461699980 29369647597 8617109927 8228554835 88622245...
result:
ok 200000 lines
Test #31:
score: 0
Accepted
time: 141ms
memory: 124912kb
input:
100000 200000 200000 200000 53010 49633 1 53010 59519 2 6816 59519 3 78502 6816 4 78502 65287 5 65287 79815 6 79815 30170 7 77879 30170 8 55266 77879 9 23789 55266 10 36254 23789 11 36254 90500 12 63249 90500 13 96436 63249 14 23455 96436 15 23455 50639 16 50639 18803 17 31685 18803 18 1594 31685 19...
output:
17988648881 16577887284 18862732776 18560246345 17967896333 17031787946 16142551184 16535909796 16199184894 8618575500 18189588395 15524071370 9582068450 18337723018 15198206715 8746439895 16959776472 9630100170 17480318912 15410785267 10186031158 16563885013 15465739549 9112083495 15103374281 16780...
result:
ok 200000 lines
Test #32:
score: 0
Accepted
time: 3691ms
memory: 121900kb
input:
100000 200000 200000 200000 88074 77343 784964706 77343 33920 563017940 33920 65056 197074779 86003 65056 772593368 86003 18121 10767262 99690 18121 126142446 99690 4622 983048761 4622 78770 404528670 78770 30756 301873082 14814 30756 720606113 14814 17313 555399219 5353 17313 669311456 5353 42445 7...
output:
1939694757433 1943263914159 2059652449729 2014173315507 2020205059253 1928378355762 1972536938721 1992141393318 2097443523837 1925806642782 1987699900928 2015985441135 1953877439799 2019283985411 2011432949943 1977454269730 2006699655212 1994248112029 2000596809879 2060499570632 1917061311677 193443...
result:
ok 200000 lines
Test #33:
score: 0
Accepted
time: 5808ms
memory: 128432kb
input:
100000 200000 200000 200000 64889 26056 615577935 26056 87979 326555643 87697 87979 70880101 762 87697 468945744 59301 762 136356981 59301 88470 314140622 86571 88470 84178287 86571 5686 648975592 5686 35905 332294411 26005 35905 878227381 26005 83741 83715961 1940 83741 149292053 1940 66359 8340825...
output:
238380891771 222869144679 201857566350 197542555767 200802324788 165764818282 180657301541 377930771395 169715235750 178106952715 184895030315 201566916541 222367048871 193358058896 210193054348 181397951582 192376070555 175466184160 207004215870 213413747399 196004500227 195867682961 183244555898 2...
result:
ok 200000 lines
Test #34:
score: 0
Accepted
time: 3181ms
memory: 134544kb
input:
100000 200000 200000 200000 41927 39820 825540785 85221 39820 958402139 24873 85221 36275855 24873 64412 448852591 64412 57978 557086229 52690 57978 114756686 52690 13065 951039813 13065 59620 481894894 59620 34221 963221378 53088 34221 814904987 77863 53088 887929175 64243 77863 465746995 17205 642...
output:
1958766813154 1995058172670 2043618064942 2010237590249 1963832906688 2047456028945 1991905253576 2031848206237 1958522649451 2001516700590 1975122737591 2001678907678 1951728039599 2039686229200 2041757834515 2025126496014 1988094159304 2001521541182 2006144111697 1997586516441 2027526404816 200119...
result:
ok 200000 lines
Test #35:
score: 0
Accepted
time: 4992ms
memory: 131804kb
input:
100000 200000 200000 200000 84169 83877 354713252 83877 55682 800771530 95605 55682 976737599 30008 95605 962237802 30008 4077 47876943 75722 4077 955894840 75722 51673 351770984 51673 22736 286967413 22736 5935 983524110 13240 5935 562060968 20445 13240 215548806 56851 20445 477035947 56851 61560 8...
output:
214888426540 203957827209 209966435614 229869244431 203984004364 201978049440 209976378310 193955687112 214973200284 213961441009 176946328948 189965088302 231937272746 183991621301 181960366887 212972527593 170916665596 205964410573 218834318872 178976418915 183952871399 219962553953 192949926304 1...
result:
ok 200000 lines
Test #36:
score: 0
Accepted
time: 2888ms
memory: 127824kb
input:
100000 200000 200000 200000 75715 47844 1 95866 75715 2 95866 4593 3 4593 21382 4 61027 21382 5 10623 61027 6 27703 10623 7 42662 27703 8 31010 42662 9 31010 482 10 482 31924 11 53600 31924 12 78790 53600 13 78790 55556 14 55556 31160 15 77757 31160 16 77757 36482 17 36482 46082 18 46082 48542 19 12...
output:
392432399 258224149 264093455 179289073 266700159 148258319 321387584 208173611 543392691 295789926 301693436 210853868 189668480 364194424 153451183 115405816 320789506 310296800 526157486 301091290 293287014 304768205 164607077 147601360 133189504 492253117 216880995 474431522 154069591 434310052 ...
result:
ok 200000 lines
Test #37:
score: 0
Accepted
time: 3627ms
memory: 131796kb
input:
100000 200000 200000 200000 82141 8386 1 8386 56069 2 56069 67235 3 29234 67235 4 29234 47483 5 47483 37283 6 36 37283 7 36 29093 8 29093 94801 9 88584 94801 10 88584 59860 11 26906 59860 12 92592 26906 13 92592 8556 14 8556 48234 15 48234 18906 16 18906 421 17 421 60284 18 60284 53817 19 19505 5381...
output:
101777034 98023466 35400293 28587857 38677424 121914782 64504529 67965466 54731458 61790154 56503694 121793011 110544768 120086538 70082272 100386617 79768033 109209420 64026716 87127754 90233317 78368001 28864113 30574793 49053303 40084165 99464318 62324680 91613034 37320823 45018845 63236050 90700...
result:
ok 200000 lines
Test #38:
score: 0
Accepted
time: 3664ms
memory: 122568kb
input:
100000 200000 200000 200000 8243 93814 1 93814 1693 2 33437 1693 3 33437 75852 4 75852 26117 5 26117 47625 6 47625 50710 7 50710 18213 8 18213 73297 9 23982 73297 10 75575 23982 11 242 75575 12 242 98850 13 98850 91515 14 98696 91515 15 81125 98696 16 37330 81125 17 37330 29595 18 66189 29595 19 855...
output:
40139024 58335765 29659079 34101035 15158897 13748491 29732490 43591029 13077901 37917925 46554593 54014688 16840757 49395128 51476313 37119304 31009275 30796093 57892847 42995950 46644098 28423888 16318454 24646627 47924906 33766165 31887121 44235847 49656633 43270712 54823797 29575512 31086272 534...
result:
ok 200000 lines
Extra Test:
score: 0
Extra Test Passed