QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700736 | #29. Posters on the wall | TheZone | 100 ✓ | 699ms | 214224kb | C++23 | 5.6kb | 2024-11-02 13:21:03 | 2024-11-02 13:21:17 |
Judging History
answer
#include<cstdio>
#include<vector>
#include<algorithm>
const int N=50007;
typedef long long ll;
int xs[N*2],ys[N*2],xc,yc;
int cl[N],cr[N],cd[N],cu[N];
struct TR0
{
static const int M=N*20*8;
int tr[M],sm[M],ls[M],rs[M],rt[N*2],vc,nw;inline void ref(){nw=vc;}
int cpy(int x){int p=++vc;tr[p]=tr[x];sm[p]=sm[x];ls[p]=ls[x];rs[p]=rs[x];return p;}
inline void pull(int x,int n){sm[x]=(tr[x]?n:sm[ls[x]]+sm[rs[x]]);}
void upd(int&k,int L,int R,int v,int l,int r)
{
if(L>R)return;if(k<=nw)k=cpy(k);
if(L<=l&&r<=R){tr[k]+=v;pull(k,ys[r+1]-ys[l]);return;}
int mid=(l+r)>>1;
if(L<=mid)upd(ls[k],L,R,v,l,mid);
if(R>mid)upd(rs[k],L,R,v,mid+1,r);
pull(k,ys[r+1]-ys[l]);
}
int qry(int k,int L,int R,int l,int r)
{
if(L>R)return 0;if(!k||(L<=l&&r<=R))return sm[k];
if(tr[k])return ys[std::min(R,r)+1]-ys[std::max(L,l)];
int mid=(l+r)>>1,ans=0;
if(L<=mid)ans=qry(ls[k],L,R,l,mid);
if(R>mid)ans+=qry(rs[k],L,R,mid+1,r);
return ans;
}
};
struct TR
{
static const int M=N*20*8;
int tr[M],sm[M],ls[M],rs[M],rt[N*2],vc,nw;
ll hs[M];int ml[M],ad[M];inline void ref(){nw=vc;}
int cpy(int x)
{
int p=++vc;tr[p]=tr[x];sm[p]=sm[x];ls[p]=ls[x];rs[p]=rs[x];
hs[p]=hs[x];ml[p]=ml[x];ad[p]=ad[x];return p;
}
void adds(int&k,int ms,int as,int n)
{
if(k<=nw)k=cpy(k);hs[k]+=(ll)ms*sm[k]+(ll)as*n;
ad[k]+=as;(tr[k]?ad[k]:ml[k])+=ms;
}
void push(int k,int ln,int rn){if(ad[k]||ml[k])adds(ls[k],ml[k],ad[k],ln),adds(rs[k],ml[k],ad[k],rn),ml[k]=ad[k]=0;}
void pull(int x,int n){sm[x]=(tr[x]?n:sm[ls[x]]+sm[rs[x]]);hs[x]=hs[ls[x]]+hs[rs[x]];}
void upd(int&k,int L,int R,int v,int l,int r)
{
if(L>R)return;if(k<=nw)k=cpy(k);
if(L<=l&&r<=R){tr[k]+=v;sm[k]=(tr[k]?xs[r+1]-xs[l]:sm[ls[k]]+sm[rs[k]]);return;}
int mid=(l+r)>>1;push(k,xs[mid+1]-xs[l],xs[r+1]-xs[mid+1]);
if(L<=mid)upd(ls[k],L,R,v,l,mid);
if(R>mid)upd(rs[k],L,R,v,mid+1,r);
pull(k,xs[r+1]-xs[l]);
}
int qry(int k,int L,int R,int l,int r)
{
if(L>R)return 0;if(!k||(L<=l&&r<=R))return sm[k];
if(tr[k])return xs[std::min(R,r)+1]-xs[std::max(L,l)];
int mid=(l+r)>>1,ans=0;
if(L<=mid)ans=qry(ls[k],L,R,l,mid);
if(R>mid)ans+=qry(rs[k],L,R,mid+1,r);
return ans;
}
ll hsqry(int k,int L,int R,int l,int r)
{
if(L>R)return 0;if(k<=nw)k=cpy(k);
if(!k||(L<=l&&r<=R))return hs[k];
int mid=(l+r)>>1;ll ans=0;push(k,xs[mid+1]-xs[l],xs[r+1]-xs[mid+1]);
if(L<=mid)ans=hsqry(ls[k],L,R,l,mid);
if(R>mid)ans+=hsqry(rs[k],L,R,mid+1,r);
return ans;
}
};
TR0 T0;TR T1;
struct pii{int l,r,v;};
std::vector<pii> xv[N*2],yv[N*2];
int T0q(int t,int qd,int qu,int td,int tu)
{
int A=(T0.qry(T0.rt[t],td,td,1,yc-1)?1:0)*(tu==td?qu-qd+1:ys[td+1]-qd);
if(tu==td)return A;A+=(T0.qry(T0.rt[t],tu,tu,1,yc-1)?1:0)*(qu-ys[tu]+1);
return A+T0.qry(T0.rt[t],td+1,tu-1,1,yc-1);
}
int main()
{
int r,c,n,q,m;scanf("%d%d%d%d%d",&r,&c,&n,&q,&m);
xs[++xc]=0;xs[++xc]=r;ys[++yc]=0;ys[++yc]=c;
for(int i=1;i<=n;++i)
{
scanf("%d%d%d%d",cl+i,cd+i,cr+i,cu+i);
if(cd[i]>cu[i])std::swap(cd[i],cu[i]);
if(cl[i]>cr[i])std::swap(cl[i],cr[i]);
xs[++xc]=cl[i];xs[++xc]=cr[i];
ys[++yc]=cd[i];ys[++yc]=cu[i];
}
std::sort(xs+1,xs+xc+1);xc=std::unique(xs+1,xs+xc+1)-xs-1;
std::sort(ys+1,ys+yc+1);yc=std::unique(ys+1,ys+yc+1)-ys-1;
for(int i=1;i<=n;++i)
{
cl[i]=std::lower_bound(xs+1,xs+xc+1,cl[i])-xs;
cr[i]=std::lower_bound(xs+1,xs+xc+1,cr[i])-xs;
cd[i]=std::lower_bound(ys+1,ys+yc+1,cd[i])-ys;
cu[i]=std::lower_bound(ys+1,ys+yc+1,cu[i])-ys;
xv[cl[i]].push_back({cd[i],cu[i]-1,1});
xv[cr[i]].push_back({cd[i],cu[i]-1,-1});
yv[cd[i]].push_back({cl[i],cr[i]-1,1});
yv[cu[i]].push_back({cl[i],cr[i]-1,-1});
}
for(int i=1;i<xc;++i){T0.rt[i]=T0.rt[i-1];for(pii z:xv[i])T0.upd(T0.rt[i],z.l,z.r,z.v,1,yc-1);T0.ref();}
for(int i=1;i<yc;++i){T1.rt[i]=T1.rt[i-1];for(pii z:yv[i])T1.upd(T1.rt[i],z.l,z.r,z.v,1,xc-1);T1.adds(T1.rt[i],ys[i+1]-ys[i],0,r);T1.ref();}
ll lsa=0;
while(q--)
{
int ql,qr,qu,qd,v;scanf("%d%d%d%d%d",&ql,&qd,&qr,&qu,&v);
ql=(ql+(__int128)lsa*v)%m;qr=(qr+(__int128)lsa*v)%m;
qd=(qd+(__int128)lsa*v)%m;qu=(qu+(__int128)lsa*v)%m;
if(qd>qu)std::swap(qd,qu);if(ql>qr)std::swap(ql,qr);--qr;--qu;
if(qu<qd||qr<ql){printf("%lld\n",lsa=0);continue;}
int tl=std::upper_bound(xs+1,xs+xc+1,ql)-xs-1;
int tr=std::upper_bound(xs+1,xs+xc+1,qr)-xs-1;
int td=std::upper_bound(ys+1,ys+yc+1,qd)-ys-1;
int tu=std::upper_bound(ys+1,ys+yc+1,qu)-ys-1;
ll ans=(ll)T0q(tl,qd,qu,td,tu)*(tl==tr?qr-ql+1:xs[tl+1]-ql);
if(tl==tr)goto prt;ans+=(ll)T0q(tr,qd,qu,td,tu)*(qr-xs[tr]+1);
if(tu==td){ans+=(ll)T1.qry(T1.rt[td],tl+1,tr-1,1,xc-1)*(qu-qd+1);goto prt;}
ans+=(ll)T1.qry(T1.rt[tu],tl+1,tr-1,1,xc-1)*(qu-ys[tu]+1)+(ll)T1.qry(T1.rt[td],tl+1,tr-1,1,xc-1)*(ys[td+1]-qd);
{int t=T1.vc;ans+=T1.hsqry(T1.rt[tu-1],tl+1,tr-1,1,xc-1);ans-=T1.hsqry(T1.rt[td],tl+1,tr-1,1,xc-1);T1.vc=t;}
prt:printf("%lld\n",lsa=ans);
}
return 0;
}
详细
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 3ms
memory: 4836kb
input:
500 500 398 500 550 174 98 170 101 413 442 406 435 394 123 486 121 360 139 361 136 7 216 8 208 282 302 284 308 134 134 140 131 160 27 161 26 437 364 442 356 162 438 173 445 180 151 178 146 1 298 24 310 255 328 254 335 119 42 128 39 22 120 17 125 81 140 85 139 98 50 100 40 101 250 98 291 53 369 37 37...
output:
588 7261 508 3 134 398 6 707 16 997 16 2274 1472 874 2604 26 85 140 35 651 2009 1082 4253 904 4 256 4061 759 278 2768 1524 3276 87 249 589 4 979 646 469 192 322 9 163 609 5748 27 177 62 34 1662 4873 140 186 1139 110 681 2778 6089 617 84 6 360 9 2 88 619 6 1680 4 3 12 2 720 5674 363 995 2153 588 4236...
result:
ok 500 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 4564kb
input:
500 500 500 500 550 83 255 65 260 372 489 367 491 311 461 303 464 57 239 56 241 377 491 357 493 401 34 413 36 84 197 92 199 367 431 377 482 417 39 418 41 122 445 125 446 325 262 316 444 64 354 66 356 440 303 430 305 446 0 444 1 227 94 226 96 348 492 352 495 147 3 161 17 177 384 178 386 249 61 248 63...
output:
5548 1292 13607 9 15 50 56 99 72 6670 214 3910 8021 70 1085 27 1442 20 2 1795 19 3243 1432 36 317 5659 20 1 58 2468 6952 1369 975 5113 27 11 8852 8825 34 2236 10 20991 7972 249 140 11494 1313 12 226 2400 33 8930 0 196 13 1102 6357 2506 350 2076 1916 2744 39 11266 4522 27 241 3124 14 67 23224 96 3591...
result:
ok 500 lines
Test #3:
score: 10
Accepted
time: 3ms
memory: 8600kb
input:
500 500 450 500 550 224 121 226 113 214 388 215 379 0 77 3 76 296 47 297 61 227 6 229 8 450 231 452 226 155 214 166 200 129 433 130 419 16 56 19 44 408 320 410 317 377 163 379 175 330 401 332 411 339 25 341 24 496 152 498 141 194 347 200 338 349 75 350 80 455 410 459 413 444 32 485 29 308 259 310 24...
output:
55 627 2566 418 418 4112 3775 12682 2837 2570 5 2555 721 20 18 463 1086 1 1749 4553 290 5727 5898 260 126 175 3514 110 24 1296 2335 4066 34 60 1874 28 7031 22 14 4306 0 16993 12422 349 250 14 22 1004 11528 487 9985 4022 105 9848 10830 11 5 3516 2692 696 8585 34 7499 6439 12 5417 16907 2427 193 36 83...
result:
ok 500 lines
Subtask #2:
score: 10
Accepted
Dependency #1:
100%
Accepted
Test #4:
score: 10
Accepted
time: 25ms
memory: 24360kb
input:
5000 5000 4800 5000 5200 2710 3951 2735 3940 87 184 82 172 533 2512 541 2513 2563 512 2566 499 1615 4388 1580 4390 1833 3669 1889 3670 4039 4697 4049 4678 3699 3873 3689 3885 1224 2032 1229 2036 4986 1372 4991 1356 856 447 836 440 2588 3438 2586 3423 1966 3513 1910 3515 107 4499 139 4501 3725 4368 3...
output:
168781 1136262 187073 190667 412944 522 7454 64644 375 9665 167538 11 3550 13 474 228911 597329 447442 212422 12665 10 224326 96 617196 359988 21 138474 33 415034 7 452020 440886 927 278284 210766 1497677 6 250378 36 808436 9587 98550 826746 6995 3720 120 585529 36 56530 302556 8899 194199 192 26009...
result:
ok 5000 lines
Test #5:
score: 10
Accepted
time: 14ms
memory: 20044kb
input:
5000 5000 4980 5000 5200 2854 4994 2805 4996 1840 1797 1826 1798 3305 997 3312 999 2594 4954 2648 4955 248 2194 274 2195 4700 4391 4742 4396 4125 4593 4072 4595 1522 571 1508 572 4389 2278 4384 2281 2820 5 2808 9 2558 715 2555 717 2242 3423 2272 3425 2728 4195 2705 4197 4487 3226 4506 3227 3787 3301...
output:
118664 495 37088 172020 46 84488 148051 18 26 70316 185614 156577 252 78 1267930 2993633 268766 972555 117 862990 140520 6586 93445 858808 10763 357789 20437 22 190 237890 1354 200827 759479 91202 826164 154254 506178 1 2 101823 1465064 1090781 3108 20 2266 854 211946 659933 24579 57 114050 63104 63...
result:
ok 5000 lines
Test #6:
score: 10
Accepted
time: 18ms
memory: 17280kb
input:
5000 5000 4500 5000 5200 4957 80 4959 74 467 1129 468 1121 3057 1998 3059 1991 4963 597 4965 615 1614 1907 1616 1914 3888 2124 3891 2151 4629 3328 4631 3285 4324 1303 4329 1245 29 3142 101 3204 2 1248 4 1304 1992 3930 1995 3895 3231 3530 3232 3511 2982 2988 2983 2951 69 4208 72 4201 2917 1485 3859 1...
output:
16 15572 32 2062433 1597338 216259 34743 1912648 385 400424 8 11622 82 190 8 931642 0 843700 41 89510 1211246 413934 812579 5610 207277 30922 10622 5555 704928 1206412 540993 23 1780877 974589 94854 1075309 161116 467419 3706 614381 2163 241519 16 52500 6 1545127 1030474 596593 358962 237424 560 129...
result:
ok 5000 lines
Subtask #3:
score: 40
Accepted
Dependency #2:
100%
Accepted
Test #7:
score: 40
Accepted
time: 202ms
memory: 107244kb
input:
300000 300000 50000 50000 1000000009 11316 299980 11337 299997 299979 56557 300000 56579 299978 275796 299999 275812 2 3542 22 3563 233935 299979 233952 299999 117047 3 117069 21 299977 271150 299998 271169 299977 270758 299998 270777 299978 191547 300000 191566 208728 299978 208747 299998 114218 29...
output:
10689151 12114250 11402068 11402654 10925798 10214409 9976388 9028134 11165219 11400860 11640231 10690181 8790055 9264776 11876266 11639748 9025446 8076639 11401718 10926794 10215019 12352448 14488845 7840301 10690047 10450183 10926264 12351568 9026898 9027100 10213852 10925063 11402462 7839831 9026...
result:
ok 50000 lines
Test #8:
score: 40
Accepted
time: 699ms
memory: 205596kb
input:
300000 300000 50000 50000 1000000009 219242 13638 218895 14093 258037 22561 258297 22834 78346 258531 78204 258303 181208 154712 181768 154614 174763 162334 174577 162195 219538 63256 219711 63208 60962 293220 60787 292605 62109 270938 62406 270327 178763 289801 178862 289330 264470 80389 264635 807...
output:
633729452 5327660 273824033 2640 49039217 408539087 13040321 1048839945 624892656 430024624 297373268 217058055 1833105182 826451293 331081022 1566854166 505156150 80019912 79 6460832 497858466 661370368 252006219 13993545 88851095 387143453 505664238 1701183345 22624907 428046 14038542 182353806 41...
result:
ok 50000 lines
Test #9:
score: 40
Accepted
time: 260ms
memory: 156416kb
input:
300000 300000 50000 50000 1000000009 10369 10381 10380 289631 83041 216960 216971 216971 27385 272616 272627 272627 149617 149617 150371 149628 57829 57829 242159 57840 111349 188652 188663 188663 126709 173292 173303 173303 57505 242496 242507 242507 113377 113389 113388 186623 63157 63157 236831 6...
output:
981244 399087 3578783337 488050 38121 1152846 297827 8051967767 7236277307 798 9095 55104 3260 333303664 14200381978 3959 1768 97 318 801953 135168 650325 221198989 1884 913950 5713966523 4 1654 124124 1274 2801458070 401 2301080535 1988 582 9559710479 159831 964135 70 40710 13313280264 693 365 1262...
result:
ok 50000 lines
Test #10:
score: 40
Accepted
time: 546ms
memory: 188896kb
input:
300000 300000 49998 50000 1000000009 183840 270291 184223 270265 150018 19037 150020 18404 280054 130561 280055 130963 188044 128475 188046 127630 20330 17547 20180 17682 125902 59390 125811 59419 186513 171098 186564 170825 60805 238683 61128 238686 126506 75374 126730 75793 75773 117217 75759 1176...
output:
362 348 2617404380 193 509798109 4558528128 791396454 33440 574167357 53783329 12590 1064 0 315800044 1803551519 138 381204744 312867133 511149368 413734868 51168 148311377 53040078 3144010727 30948552 906318245 2189285412 9981234 332464226 1808999322 543 773275337 3306833002 83 1660978755 2386800 2...
result:
ok 50000 lines
Test #11:
score: 40
Accepted
time: 389ms
memory: 153704kb
input:
300000 300000 50000 50000 1000000009 152596 84274 152622 84277 263611 289584 263158 289585 49870 191102 50315 191104 268692 63 267874 65 262537 77571 262510 77572 200002 213 199901 215 284620 140803 284688 140805 76459 79 76380 82 6733 219078 7057 219079 229429 118927 229884 118928 129594 188 128897...
output:
3388633577 305247649 492499344 27090 305 0 3594680815 79782179 486331714 668483269 5077713 0 6036811 1507863145 749255944 988565473 328885688 4808113939 5272 4308022905 1564 285887035 2433797086 10126 853395966 3972827210 563404748 1268821801 2445 5463572994 36108596 2013903 628 277352682 702 270 20...
result:
ok 50000 lines
Test #12:
score: 40
Accepted
time: 363ms
memory: 157492kb
input:
300000 300000 50000 50000 1000000009 299687 39990 299688 39295 299960 230987 299964 230642 231571 77246 231573 76450 206654 287283 206656 287092 97015 20459 97016 21336 119004 179676 119006 179890 299891 75215 299893 75711 273252 26302 273256 26030 268435 133282 268438 133839 147455 206968 147456 20...
output:
5828939340 9927699 297771745 2180769347 37 529710605 15 19737 982108237 1226248881 111151716 135931 524897291 910486486 2820700741 3758257522 5838 3249386440 1451331900 1055170404 975 1564993497 0 211608178 4958869 1111697156 33256 2119005836 1540157162 2 4331508059 641 940896748 1339382583 812 3842...
result:
ok 50000 lines
Subtask #4:
score: 10
Accepted
Dependency #2:
100%
Accepted
Test #13:
score: 10
Accepted
time: 215ms
memory: 149856kb
input:
1000000000 200000 50000 50000 1000000009 171990547 0 172057583 14 999930563 186570 999999382 186583 79927795 199985 79978217 200000 461165456 199985 461229356 199999 999920984 100545 999991031 100558 5868 36931 71469 36944 999928238 158400 999989482 158414 357175014 199985 357234078 200000 6715 7504...
output:
19580390318 28138262788 21974981742 23951322902 24171323936 18264614169 17774659215 21561395836 18076054992 20298214032 26513716520 24338985718 15776825497 27535122242 22937846202 26405046539 26451511701 26289239601 28664481075 21146290997 21571570402 14852519558 20624251932 17782836572 16099016518 ...
result:
ok 50000 lines
Test #14:
score: 10
Accepted
time: 658ms
memory: 207112kb
input:
1000000000 200000 50000 50000 1000000009 492423888 78363 493322827 78019 633273964 115755 632131915 115534 715163025 186945 714551078 187160 49509017 163400 49349473 163172 340537938 36983 340150970 36916 583582466 30163 585746282 30101 304915421 117105 306187953 117041 155681299 51306 155738324 517...
output:
5064990714 466256643193 245557568609 791260325735 779833804255 22208615 98578320 518933677732 803816123665 6513401934010 37050959041 7573767 2117628055783 100258 480042829810 26597921105 1449133381323 264380990162 139001264745 1551278802202 305 520169406638 137841895324 504252494257 257476444763 143...
result:
ok 50000 lines
Test #15:
score: 10
Accepted
time: 266ms
memory: 156520kb
input:
1000000000 200000 50000 50000 1000000009 259280001 51865 259320000 148143 339040001 132192 660999999 132199 346080001 130784 653959999 130791 233400001 153320 766639999 153327 542480000 91497 542519999 108495 322000001 64401 677959999 64408 340240001 131952 659799999 131959 563120000 87369 563159999...
output:
2318237 1128366322 2448040057429 1002 3323724 5377344 2807354 16588791 12338088262830 1638384696 1586260326466 54521975658331 2596778496 1697348289 13600812017707 760216576 521888191 602 2218243901 4983605091508 30370084021796 2360 8164710 5610 1478 10136 244239240 40575022142744 1413 1412 540146100...
result:
ok 50000 lines
Test #16:
score: 10
Accepted
time: 524ms
memory: 189644kb
input:
1000000000 200000 49998 50000 1000000009 118431338 15793 118346372 15663 896456053 9156 896456055 9546 633702438 104252 634926254 104206 662628913 173441 663708641 173603 566518305 185976 565739600 185749 631288697 70958 631288698 70640 81505711 71563 80971755 71677 639541662 61623 639541663 61558 1...
output:
3444879948760 2127535359662 5255339138168 253281496950 1190854383470 6767224055777 938196 135802788068 487261485630 3257276 100590399 988308532997 172 4229725711338 6659838 68176231689 0 166194205056 41831947096 366219637193 403380981174 948439809 754897676629 769595815202 10012682546852 15811003509...
result:
ok 50000 lines
Test #17:
score: 10
Accepted
time: 408ms
memory: 154604kb
input:
1000000000 200000 50000 50000 1000000009 16622053 173037 14997618 173038 467432112 30 468426556 31 702524067 96609 704429269 96611 94891623 72042 95837965 72044 532731921 126201 531581723 126203 320725330 121954 321016552 121956 784264851 111175 784956238 111177 121864487 163063 123464917 163065 429...
output:
32275095 3333133287132 121250000721 616592695828 1678509204573 1807799 2337006 8840534822 15944672060 6174943884881 14006801063749 18891264 8172862605638 20008660884119 2642756736840 17349220815866 103202848568 1689507114260 1282622526172 600080250461 4627316490740 2346 7896647754357 6243894160230 3...
result:
ok 50000 lines
Test #18:
score: 10
Accepted
time: 360ms
memory: 154784kb
input:
1000000000 200000 50000 50000 1000000009 646001236 102099 646001239 102091 714115615 20050 714115616 20154 991694437 15447 991694438 15190 965222744 103031 965222748 102825 171285 66817 171286 66095 997756058 24317 997756060 24547 429645203 45753 429645205 46253 436413735 47821 436413737 47387 48215...
output:
7349433750 4631057211002 4062574335134 17268887982 7963801235276 462 1709307 1670619172219 11573106902378 0 824815498788 0 152771712 116388944120 8762806859289 276069153454 4323595472460 116 1698109908188 3165767599314 3970332193503 14463848790584 765328728378 14106174608729 1476767335824 4234578689...
result:
ok 50000 lines
Subtask #5:
score: 10
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Test #19:
score: 10
Accepted
time: 257ms
memory: 212056kb
input:
1000000000 1000000000 50000 50000 1000000009 11560 437654867 77326 437718940 390451542 999927886 390510545 999994478 547078826 335 547142769 66829 615875834 999927018 615941639 999997709 9543 19520043 64336 19582719 3588 553960559 79850 554026247 999920185 899215185 999998864 899272128 7131 40164814...
output:
94891829539711 62938793578662 82754294978013 114067141133271 127645082686034 98347707117269 94601172909988 112260376839577 64576079879015 88185649278695 117039103109700 111891034126264 92737879567848 94077078713005 154443043413393 79934614882148 88488941813652 88216814645170 95212094581227 127183692...
result:
ok 50000 lines
Test #20:
score: 10
Accepted
time: 648ms
memory: 214224kb
input:
1000000000 1000000000 50000 50000 1000000009 459300307 8896473 461220893 6380582 246046884 370912369 246909539 369317016 383513692 506333984 381805278 508401801 324819350 925666762 326183023 928298303 514122525 906342427 513647613 907724132 226277320 383828899 228709443 381226718 799267679 435861408...
output:
2811251784190965 6383048192487043 741989201213 539766429489 771044657635785 1962866201779781 1873985319202675 3277041219356771 7679575975229257 340354569491797 5889603806917327 259741433392 2167150917479067 476715942300 142903567665778 2926602 784305969037560 2285832 3532353495253480 222389038462464...
result:
ok 50000 lines
Test #21:
score: 10
Accepted
time: 228ms
memory: 155688kb
input:
1000000000 1000000000 50000 50000 1000000009 472040001 527960000 527999999 527999999 215600001 215640001 215640000 784399999 641440000 358520001 641479999 641439999 307840001 307840001 692119999 307880000 366240001 633760000 633799999 633799999 269440001 730560000 730599999 730599999 456000001 45604...
output:
9944586 86458820784649586 9439078 15831390102726 3555077826726 6276018 50696353739352729 546317358217160435 1238892096 576642 276192147798544218 3003003 1626019428616 50483891502546589 7444414 21593548832409102 1848490319016 634867894544217 1549495747041 14071053 2146240 7300865 258312 3393249980 65...
result:
ok 50000 lines
Test #22:
score: 10
Accepted
time: 540ms
memory: 197128kb
input:
1000000000 1000000000 49998 50000 1000000009 597649927 813542160 599684956 813991346 365563509 987156524 367894191 987156528 539900079 965276822 539576395 965942616 604926877 531599063 604244098 530770736 644444990 23519094 644444992 23751787 708233374 842515650 709249194 843499912 648761404 3693068...
output:
14859049273632 4969732809222048 40275920000 5173877849541613 57648916013722 56310161735870671 685336082700 8945684455648888 3388249890584471 5106899 5057190598901577 0 14907609133828992 512305874709223 7045730355938569 2815941417754096 13963445069398214 569442510351090 17287162087889922 789312261143...
result:
ok 50000 lines
Test #23:
score: 10
Accepted
time: 380ms
memory: 160140kb
input:
1000000000 1000000000 50000 50000 1000000009 418606359 9078158 416977486 9078160 959547389 312715817 959061071 312728456 265184036 723547909 265416329 723547912 984615770 48390969 984253938 48390971 361710339 378078779 363323338 378078782 337405302 583503463 337447917 583503465 647762681 355120999 6...
output:
6649338536714325 13207169073121945 512094682480951 4042349951191514 3808623506516810 482003935048797 38758078190351244 12652096257436981 2176951225142613 53959374486792665 46099937700779226 18698265431260775 2829924187524 785243291700 14255951529343307 1311310592874 23352789938611887 2555109 3296768...
result:
ok 50000 lines
Test #24:
score: 10
Accepted
time: 370ms
memory: 165964kb
input:
1000000000 1000000000 50000 50000 1000000009 398783843 289363817 398783845 288645296 435113816 790570881 435113818 791435247 994550006 553096001 994550008 552827297 153027216 579978355 153027218 579995719 169586110 678740914 169586112 680260365 999533946 431827610 999533949 429724533 452039946 99249...
output:
10564932599512658 654947488 3605556767828639 27470391876798668 7554629325007381 16949373469972400 13401149821205482 1160580589765361 3332472244036217 2345708962518253 55115070748764259 1407102606707266 8171493476010028 9381374845649044 37794139189495980 108288865651654 46011709247222906 883881806100...
result:
ok 50000 lines
Subtask #6:
score: 10
Accepted
Test #25:
score: 10
Accepted
time: 150ms
memory: 83092kb
input:
100002 100002 50000 50000 100003 26929 99995 26935 100002 22715 99995 22721 100002 0 14154 6 14160 0 14203 6 14209 0 57260 6 57266 8057 0 8063 7 39109 99995 39115 100002 0 38521 6 38527 0 82355 6 82361 37037 99995 37043 100002 83083 99995 83089 100002 0 4746 6 4752 84357 99995 84363 100002 1659 0 16...
output:
1349982 1349972 1124973 1199974 1274979 1274970 1274978 1349973 1274978 1274970 1199974 1274968 1199974 1349972 1274978 1199974 1199976 1124973 1349982 1274968 1199976 1274968 1274978 1349973 1124973 1274979 1199974 1349973 1274970 1424976 1199974 1349972 1199976 1349982 1274970 1274968 1199976 1274...
result:
ok 50000 lines
Test #26:
score: 10
Accepted
time: 588ms
memory: 189468kb
input:
100002 100002 50000 50000 100003 61026 2370 60994 2229 87569 19895 87405 19848 49417 62393 49441 62528 6180 32280 6213 32121 56743 85926 56803 85912 15858 49815 15968 49885 66405 21955 66324 21895 56506 53049 56453 53080 48704 43673 48432 43797 57883 95673 57749 95837 30331 28165 30404 28101 76960 1...
output:
55218205 57726276 114393 73500936 313273888 76466337 6532211 30690923 4479241 163547586 39611468 67570220 9028933 4113334 43386625 5496 7475997 68108974 1710573 134915736 247954944 84101591 230 44590253 10114340 249443514 190781494 76387649 82501134 57862120 29105371 16 96 100 61 3823399 26461746 22...
result:
ok 50000 lines
Test #27:
score: 10
Accepted
time: 281ms
memory: 155216kb
input:
100002 100002 50000 50000 100003 19062 19062 80936 19065 78381 21618 78384 78380 72893 27106 72896 72892 62481 37518 62484 62480 29298 29302 29301 70704 11014 11018 11017 88988 26618 26622 26621 73384 26006 26006 73992 26009 61549 38450 61552 61548 96525 3474 96528 96524 922 926 925 99080 79837 2016...
output:
24992 38924880 682 111834 33 1411582205 968526816 1228 650 512 1694700361 408350565 735637798 26 975 119070 14000 87142 332775 3368367719 6048 368 4737150906 342 653 32 2052147773 162 344 31571 1718304899 92 16515 652 118 336 3086690066 1073891889 1109664418 9782 286 464 7625 4401 777813788 60 681 4...
result:
ok 50000 lines
Test #28:
score: 10
Accepted
time: 492ms
memory: 175612kb
input:
100002 100002 49998 50000 100003 41047 37537 41155 37394 16172 66804 15843 66855 32743 83551 33035 83552 42693 1553 42722 1694 80401 78839 80400 78808 79681 39014 79683 39068 20563 56905 20279 56907 34262 300 34271 428 58420 62317 58402 62413 58203 361 58205 67 10181 12778 10034 12549 16500 92224 16...
output:
12640352 700775908 117677935 25546059 159762694 247554151 423090941 439816061 183476418 3136 25962287 20365431 107657197 5250 18024084 3157 48451868 97498517 10 90444183 367338954 204 141356678 198845612 103733679 62561441 372966265 118780292 237173932 88623226 19328 80136381 1776 41076 30084749 396...
result:
ok 50000 lines
Test #29:
score: 10
Accepted
time: 362ms
memory: 143384kb
input:
100002 100002 50000 50000 100003 57286 99729 57341 99730 93395 54162 93495 54164 47385 99956 47432 99958 42690 97346 42375 97347 16757 65288 16625 65292 1785 455 1796 457 8088 9622 8461 9623 41548 26888 41566 26890 73450 92243 73308 92245 83330 99887 83291 99888 76243 2997 76063 2999 74895 2840 7483...
output:
347022588 717323382 182952625 42620180 1069819 19607751 248 387869084 305640 52177075 224566945 373923395 43894837 10704308 1593 113037393 58380059 15278873 1300588 48 196 5353584 274 17374 3537082 42867027 28184038 3422567 376250287 338 37307912 270757167 63916990 11970 132854984 5292 305 118267191...
result:
ok 50000 lines
Test #30:
score: 10
Accepted
time: 364ms
memory: 147112kb
input:
100002 100002 50000 50000 100003 11872 42256 11873 42173 55368 67932 55371 68064 66285 92923 66287 92822 2741 6933 2743 6865 6620 235 6621 136 99991 68634 99992 68557 2004 38602 2006 38421 2996 29254 2998 29314 98557 7320 98559 7301 99981 93035 99982 92953 9 66135 13 66222 50986 45678 50988 45513 72...
output:
310 322 296046988 67683 154182427 95 22294043 40 55832763 22469299 7550 1798 25312037 287925735 20216321 120978752 17707796 2772 312 580 122133117 68052420 42937600 175050622 626269884 228416933 5084 168791004 73162650 357268150 51394316 478 194531434 85217438 6790 20708163 74 666 55116714 85704280 ...
result:
ok 50000 lines
Subtask #7:
score: 10
Accepted
Dependency #6:
100%
Accepted
Test #31:
score: 10
Accepted
time: 250ms
memory: 211892kb
input:
1000000008 1000000008 50000 50000 1000000009 999924735 351743365 999992183 351801001 9525 559323373 77375 559382525 999920242 218863684 999991673 218930771 821143985 999925043 821204783 999991054 8661 190554873 65383 190620291 999932463 396536161 999984070 396604729 14375 329905907 72242 329961809 3...
output:
121610339654036 96809813433620 100302345680668 80040488558466 111940647527069 100167312056256 99041025604671 55537186572372 74193387832492 153709687639002 75348935562332 125978727025532 103755910988688 61527106095455 91665164469880 84871644106875 69270928918838 96910930719639 127442306693938 1102483...
result:
ok 50000 lines
Test #32:
score: 10
Accepted
time: 672ms
memory: 212428kb
input:
1000000008 1000000008 50000 50000 1000000009 806033065 738892032 805979587 739329127 73949747 496396506 72833285 496835167 182869858 380863815 183902518 380347249 524670538 250495680 526319209 251463814 353343127 548474500 354139596 548532893 836263573 340987627 834744625 341848640 428220244 1716169...
output:
7109491796862095 7119605761384813 4554368038920280 2172692970484367 11156807967062988 323734069425657 16984411032634590 1931419291223011 12452167849086106 4715081765739384 2247242276040 2000716509358951 34843820659940 1249990779353 3220578 1256377985838 2893379271058 98893175967 221413670520 2624389...
result:
ok 50000 lines
Test #33:
score: 10
Accepted
time: 254ms
memory: 155656kb
input:
1000000008 1000000008 50000 50000 1000000009 90640005 90640005 909320003 90680004 410400005 410400005 589560003 410440004 350120005 649880004 649920003 649920003 386200005 386240005 386240004 613800003 84640005 84680005 84680004 915360003 594600004 405360005 594640003 594600003 153680005 153720005 1...
output:
5281806022662 2344393932550 4209438 420434488272 730326344301 495325 12115828 2643720466 914377544901 7782028996860 8108958 4764120 1995444 16549712 4295086 350443685466 3531526 350186709024 9583413 3573234428855 21376902 57174930369575512 6175977422010 314011218260003130 1274124326750 3799538 45546...
result:
ok 50000 lines
Test #34:
score: 10
Accepted
time: 535ms
memory: 195376kb
input:
1000000008 1000000008 49998 50000 1000000009 789463740 726375540 788608839 727786540 568499024 79145072 568499027 78017486 569558265 647045394 569591446 647103694 829213669 556884450 830116032 556723620 509735954 622653977 509753072 622389436 612887200 248170355 612887202 247275712 551692925 8813929...
output:
18268361996571755 1437592255577027 1910930 7089030207101115 5111625200166980 13879452748129732 28724822019108800 17490056859374306 4039537191237572 696303159926323 245702012444273 349542960 36812403185679575 23578046348629943 3766797780102228 2626234040864 15980205361226156 3663595621399748 15362529...
result:
ok 50000 lines
Test #35:
score: 10
Accepted
time: 378ms
memory: 160120kb
input:
1000000008 1000000008 50000 50000 1000000009 702884571 998751669 701476940 998751670 197287616 520468246 196453820 528274138 107457185 956674356 110804586 956674358 480901803 979410649 477721680 979419210 701376338 822088879 704046987 822088880 867152186 933231032 867192731 933231034 986854333 52734...
output:
4562508346660317 6805302777 3205671714648516 5504892844530540 568970211898 533438 11828419555500916 47186853228590248 8526528 6793541732703923 7664177299912791 383664069082 63278897898931510 13553987656250859 2335656 1101555867505232 34202990747036995 907920414681 20494899932641877 11002236985124210...
result:
ok 50000 lines
Test #36:
score: 10
Accepted
time: 383ms
memory: 166928kb
input:
1000000008 1000000008 50000 50000 1000000009 207267194 513214484 207267196 509061877 478721131 938690369 479113997 939002345 997738469 946526868 997738471 947025295 56058681 823709998 56058683 821676425 998740313 457339714 998740314 455654413 58152806 24057525 58152809 23941928 91330292 859564612 91...
output:
387632154609 31483190807970996 2203103770545575 15071119681060704 667622157964 6403582119079496 2144242634660019 1685068549611876 414491420949875 2515438116450 21966186989520551 1836604400272988 4160562592320672 8796927966645857 7897793215067509 3370849705440 2251966 691828461381653 3256856434338067...
result:
ok 50000 lines
Extra Test:
score: 0
Extra Test Passed