QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#775711 | #70. Bitaro, who Leaps through Time | Symbolize | 0 | 250ms | 79228kb | C++17 | 3.5kb | 2024-11-23 16:32:10 | 2024-11-23 16:32:10 |
Judging History
answer
/*
Luogu name: Symbolize
Luogu uid: 672793
*/
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
#define rep1(i,l,r) for(register int i=l;i<=r;++i)
#define rep2(i,l,r) for(register int i=l;i>=r;--i)
#define rep3(i,x,y,z) for(register int i=x[y];~i;i=z[i])
#define rep4(i,x) for(auto i:x)
#define debug() puts("----------")
const int N=3e5+10;
const int inf=0x3f3f3f3f3f3f3f3f;
using namespace std;
int n,q,ans[N];
pii p[N];
struct Query
{
int opt;
int a,b,c,d;
}Q[N];
struct Segment_tree
{
int pl[N],pr[N];
struct node
{
int l,r;
bool res;
int x,y;
int z;
pii get(int st) const
{
if(!res)
{
if(st<x) return make_pair(x,0);
if(st>y) return make_pair(y,st-y);
return make_pair(st,0);
}
return make_pair(y,max(0ll,st-x)+z);
}
friend node operator+(const node &a,const node &b)
{
node ans;
if(!a.res&&!b.res)
{
if(a.x>b.y) ans={a.l,b.r,1,a.x,b.y,a.x-b.y};
else if(a.y<b.x) ans={a.l,b.r,1,a.y,b.x,0};
else ans={a.l,b.r,0,max(a.x,b.x),min(a.y,b.y),0};
}
else if(!a.res&&b.res)
{
if(b.x<a.x) ans={a.l,b.r,1,a.x,b.y,(a.x-b.x)+b.z};
else if(b.x>a.y) ans={a.l,b.r,1,a.y,b.y,b.z};
else ans={a.l,b.r,1,b.x,b.y,b.z};
}
else
{
pii now=b.get(a.y);
ans={a.l,b.r,1,a.x,now.x,now.y+a.z};
}
return ans;
}
}tr[N<<2];
int ls(int p){return p<<1;}
int rs(int p){return p<<1|1;}
void push_up(int p){tr[p]=tr[ls(p)]+tr[rs(p)];};
void build(int p,int l,int r)
{
tr[p]={l,r,0,0,0,0};
if(l==r)
{
tr[p].res=0;
tr[p].x=pl[l];
tr[p].y=pr[l];
return;
}
int mid=l+r>>1;
build(ls(p),l,mid);
build(rs(p),mid+1,r);
push_up(p);
return;
}
void update(int p,int x)
{
if(tr[p].l==tr[p].r)
{
tr[p].x=pl[x];
tr[p].y=pr[x];
return;
}
int mid=tr[p].l+tr[p].r>>1;
if(x<=mid) update(ls(p),x);
else update(rs(p),x);
push_up(p);
return;
}
node query(int p,int l,int r)
{
if(tr[p].l>=l&&tr[p].r<=r) return tr[p];
int mid=tr[p].l+tr[p].r>>1;
if(r<=mid) return query(ls(p),l,r);
if(l>mid) return query(rs(p),l,r);
return query(ls(p),l,r)+query(rs(p),l,r);
}
}seg;
int read()
{
int x=0,f=1;
char ch=getchar();
while(ch<'0'||ch>'9')
{
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9')
{
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return f*x;
}
void solve()
{
seg.build(1,1,n-1);
rep1(i,1,q)
{
if(Q[i].opt==1)
{
int x=Q[i].a;
seg.pl[x]=Q[i].b+n-x;
seg.pr[x]=Q[i].c+n-x;
seg.update(1,x);
}
if(Q[i].opt==2)
{
if(Q[i].a>Q[i].c) continue;
if(Q[i].a==Q[i].c)
{
ans[i]=max(0ll,Q[i].b-Q[i].d);
continue;
}
Q[i].b+=n-Q[i].a;
Q[i].d+=n-Q[i].c;
pii now=seg.query(1,Q[i].a,Q[i].c-1).get(Q[i].b);
ans[i]=now.y+max(0ll,now.x-Q[i].d);
}
}
return;
}
signed main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
n=read();
q=read();
rep1(i,1,n-1)
{
p[i].x=read();
p[i].y=read()-1;
}
rep1(i,1,q)
{
Q[i].opt=read();
if(Q[i].opt==1) Q[i].a=read(),Q[i].b=read(),Q[i].c=read()-1;
if(Q[i].opt==2) Q[i].a=read(),Q[i].b=read(),Q[i].c=read(),Q[i].d=read();
}
rep1(i,1,n) seg.pl[i]=p[i].x+n-i,seg.pr[i]=p[i].y+n-i;
solve();
rep1(i,1,q)
{
if(Q[i].opt==1) Q[i].a=Q[i].a;
if(Q[i].opt==2) Q[i].a=n-Q[i].a+1,Q[i].c=n-Q[i].c+1;
}
rep1(i,1,n) seg.pl[i]=p[n-i].x+n-i,seg.pr[i]=p[n-i].y+n-i;
solve();
rep1(i,1,q) if(Q[i].opt==2) cout<<ans[i]<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 13884kb
input:
20 18 115497790 671208773 326245299 528973482 100582193 437996818 89058008 771100620 768935396 842907844 187943946 997369106 455078418 542835554 536691525 970171971 564540350 570234421 657178750 753833933 386375484 979995375 389681484 772601117 634873482 897954663 87193815 139420775 259946990 394597...
output:
1155445816 286505553 517757980 236944355 561949186 106582836 0 610376978 191096499
result:
wrong answer 8th lines differ - expected: '304461403', found: '610376978'
Subtask #2:
score: 0
Runtime Error
Test #42:
score: 30
Accepted
time: 204ms
memory: 76192kb
input:
274318 300000 489215489 676617321 780126019 788585486 556851007 580284394 233372413 595198772 519202713 898223077 502895565 696411826 206200999 769856900 270143414 346344669 729812429 901771242 663771137 938786194 472985796 990513077 846601694 992055636 178982840 919444964 27052680 316046043 8183731...
output:
2849147975708 3843046238428 4095601609850 9126786831492 441666160010 4429060670616 6742720280622 10766622641576 588806818956 4531560125304 3895414541258 8791722334108 6126584591501 6704860308139 6957107549525 7807342130069 46968789226 1110092057560 2141002313351 5188051547992 446258629063 5203914165...
result:
ok 300000 lines
Test #43:
score: 30
Accepted
time: 213ms
memory: 53256kb
input:
258046 300000 11983062 622191570 268492608 929745787 51607741 404913324 51921703 598728123 62699122 952231709 461578449 531416802 97452666 244060641 122158096 287941223 720296043 791346846 380523240 667159781 170326069 939634145 340576754 920907881 106222111 231343077 423062506 793598284 168831686 5...
output:
8863223634241 8940016880595 951056695393 998044306671 3188238224524 5256550722611 6120010363132 5617570270290 1034399900555 9533134694478 7639790391713 4893283091708 9308833299500 615593558312 3474569143959 2806842723337 2108546311349 5178044885702 1750686320620 3926039900962 10286185698662 38507739...
result:
ok 300000 lines
Test #44:
score: 30
Accepted
time: 214ms
memory: 54592kb
input:
261488 300000 291006073 712811860 603668403 975312821 89397406 704867732 906594309 962222938 169718921 893349526 179625126 925179251 773403821 804247348 271817634 867367241 564200633 792032662 521367821 603715441 69897520 796371179 611222441 839855247 4934588 151961654 242902139 319451383 96128880 8...
output:
6872680546782 3720639456249 542418167974 5064185283762 2744907324674 2164561113205 2892288132204 3309599385634 5011502938654 2577560616373 4916208406937 7707492950027 4697668901231 5710499877253 8773367315581 10252056807727 12228741245360 1981215542503 4742929680210 5527836781069 655865079740 347278...
result:
ok 300000 lines
Test #45:
score: 30
Accepted
time: 231ms
memory: 53444kb
input:
252688 300000 769946733 792799322 188358933 667131699 911706885 932433440 50026329 257465359 478187278 774596880 332534513 728895956 566921754 960899937 164337334 290850355 80935298 640977014 34221442 329342708 168124572 533500714 519868337 874323048 272906561 521408108 795968469 995652037 686688909...
output:
8329273160704 2961827289099 4784969239281 6036048930889 7254530501396 8924463794068 7929861767734 888395634642 5308120782791 9750372025595 620374153718 11778033994042 1698464248897 3893734831952 9581775783609 11897927948006 11885374223612 7106418574425 5023254872652 1674538689705 8771929690439 12555...
result:
ok 300000 lines
Test #46:
score: 30
Accepted
time: 223ms
memory: 77160kb
input:
273557 300000 274092755 799957963 714524720 935405641 918203812 978081465 403082144 702280293 36564523 158773560 183885456 837314257 414346605 964483807 540835981 895256230 311514759 944553417 64694257 328951079 594168986 677251771 608271805 826341922 414850619 657223125 108558862 529949199 53667578...
output:
1933140756959 6862932852158 8912608683159 6316227787659 7882327128782 13064954804223 3589742634084 9429257735941 2193944731741 3853710649526 12585087864431 12051281905971 5394757361564 2779579207304 1339248268517 6504554398484 6110582960743 4604938166872 2009818490270 6389387977793 8347261199051 386...
result:
ok 300000 lines
Test #47:
score: 30
Accepted
time: 216ms
memory: 77176kb
input:
268484 300000 454828821 617074139 408335776 516183900 169088645 367190477 464230910 638434936 954966297 973456192 229155818 533423920 780685057 984601300 304158821 773168479 352122891 394291407 483147149 542579887 44217926 186766403 146533060 460798117 276184796 625417905 762786324 939271528 1040447...
output:
4756872049439 4008253389190 4057075294621 829771508032 5347459037344 9958644551370 2240163573584 3833075744548 11783686448650 3379849855705 11975601021025 9056996771461 5684410720379 1023217052632 1910462002113 4510171790197 1771383208126 3226554527467 3516959805789 270487458722 6064817046165 479852...
result:
ok 300000 lines
Test #48:
score: 30
Accepted
time: 202ms
memory: 77168kb
input:
277810 300000 552418479 552418505 22740198 22740223 48286218 48286231 48286282 48286295 48286217 48286297 360713836 360713842 293592292 293592379 293592308 293592326 293592339 293592342 48286212 48286286 485609384 485609407 293592362 293592383 477701819 477701840 48286236 48286280 48286222 48286245 ...
output:
3843631279889 716284947326 3853508715126 4534052985918 8638842210476 6378967406668 1094988789871 17875397654988 20875449338424 26344001373597 12147695164756 15440002807590 6018019432533 4453197425556 9467688959628 3356640806064 482681371251 26994930504149 20014621848026 8473602237382 3569750633826 1...
result:
ok 300000 lines
Test #49:
score: 30
Accepted
time: 220ms
memory: 79152kb
input:
289913 300000 771464804 771464815 638418620 638418625 638418606 638418624 799573029 799573038 755883975 755883980 659596941 659596958 799573040 799573045 311674300 311674317 638418613 638418621 311674313 311674315 354529107 354529108 354529103 354529109 755883974 755883976 771464795 771464812 311674...
output:
11437273541325 10864630577373 13066472954227 15689338813532 15445580041415 27250180027014 26783803913262 27204274722372 13369290119208 7111499841459 16549641855172 10710245110987 27290052414119 3132698165122 14624138644613 3448919656781 6096608729648 28416655092040 23541729235594 12265798041318 4700...
result:
ok 300000 lines
Test #50:
score: 30
Accepted
time: 192ms
memory: 54628kb
input:
254720 300000 767949724 767949757 746710180 746710221 458098810 458098823 309988385 309988403 309988377 309988396 178505951 178505959 102541948 102541949 458098787 458098832 458098804 458098823 371667830 371667854 371667819 371667822 396002015 396002024 458098819 458098829 102541950 102541955 371667...
output:
3365863718474 3805023742387 4859251992295 6718828049320 10713178744402 2081764905787 16717111077635 1481692113853 62664698165 11805697357795 1524905926619 1030275840595 13179598432270 7119722780955 2594779362557 21200038210860 24401982541697 11796069595917 3916632656305 20420286877483 3410983350337 ...
result:
ok 300000 lines
Test #51:
score: 30
Accepted
time: 214ms
memory: 77172kb
input:
276647 300000 379298184 530980614 920097352 950266261 141635915 603069280 154124994 794357348 180633687 979572320 203655841 490642999 436352462 857903059 174375597 905368722 578560917 702271269 230100851 237108445 245372722 936521889 534750405 823911807 447221469 680827793 767546299 992941848 382004...
output:
1610985713118 2872165401914 5914577894824 14220787762964 1984082872109 7894074124034 4833845285108 1451498866351 4516971177210 3040897429261 1385675227548 6748829451962 57910848308 4850003016267 6016539396427 6661837073961 13610371362307 2536399197990 579965229941 5234708461524 10562286002620 203215...
result:
ok 300000 lines
Test #52:
score: 30
Accepted
time: 206ms
memory: 79220kb
input:
274083 300000 315361995 674070869 524829122 763364637 193277765 340483781 453210022 913512527 40878867 543700898 313814292 770126339 567870316 770864615 237268888 627690880 471461378 766285597 454055304 675820194 455662972 883443281 105781705 795273784 456605642 488756853 611562497 645464863 2821271...
output:
5764492383464 8397536507770 5406628379183 7983266174941 7152051283051 5708585930417 3626864742839 2670568633304 3014950680567 4338874050106 3034236085446 11744150566787 8433663014931 3123977218630 3393949440515 13100187594050 990000980278 4829535655261 5444902921139 1888313195077 6327004808325 11989...
result:
ok 300000 lines
Test #53:
score: 30
Accepted
time: 205ms
memory: 79228kb
input:
295157 300000 140308003 749795544 454007057 890104492 458161289 629488779 905771682 965867647 202674252 411328608 805350795 808129692 331428766 803875203 129619140 980565883 854777245 977913266 293301424 484356998 546741797 985685852 120737241 184772371 622068507 793246125 734694913 852770312 192830...
output:
8002327904655 785878423725 8860311818309 3007750699746 10693971352415 3251652711689 1216265527655 1554223978294 6952709933884 13377437130325 14039452276802 10079973881909 6840054169605 7239801885214 7264254503038 6855506683023 8790859523528 2527446943637 160449247930 1391455921919 6150519289764 1513...
result:
ok 300000 lines
Test #54:
score: 30
Accepted
time: 224ms
memory: 77188kb
input:
300000 300000 338090149 966393289 464867496 895102269 362576024 688397940 286771602 919486311 545079476 839133025 442849261 553493380 45926426 356381209 494063722 806433093 48503707 531707294 355865779 509685284 144631135 702641240 665583238 703800618 67436 424516348 634338973 708475209 702370754 83...
output:
1145822456675 582173992372 4900752007278 5641190279838 6689649622749 12988920928320 7475614271370 9752494911610 11418907599096 2223840736424 6322097957459 7940068183673 4670483611439 7366827282105 828273844130 6550100948260 6389762152517 9404625687311 654245269948 9592097685148 2516955933938 9950707...
result:
ok 300000 lines
Test #55:
score: 0
Runtime Error
input:
1 100 2 1 893853055 1 295967314 2 1 306328354 1 627065661 2 1 604631783 1 309804033 2 1 179341974 1 217709789 2 1 663986744 1 498914867 2 1 411622869 1 581004973 2 1 303741472 1 622429214 2 1 973738566 1 998806809 2 1 939082066 1 433702386 2 1 876459076 1 82409520 2 1 341196842 1 849490589 2 1 57237...
output:
result:
Subtask #3:
score: 0
Wrong Answer
Test #56:
score: 0
Wrong Answer
time: 250ms
memory: 79160kb
input:
270695 300000 513123795 772355425 210106247 394028231 276162603 911454418 105669187 977348162 173662950 272706156 152814457 669922258 344843731 523572913 316675910 752220119 109044474 322732409 555169512 652867118 622530606 779759913 153668285 339269709 150911093 937002300 186921016 855255616 118867...
output:
6546692930373 1147915030312 9771877069345 1119704562225 3602711301295 3345329466188 8703957632138 1212731543002 3001190474356 6022602583263 10932435459658 3426986196964 5639811302245 4278986493716 4905678737163 2895778161036 5882530811177 10163872384436 2379294888967 5875928707705 7679043988101 4490...
result:
wrong answer 1st lines differ - expected: '6546523326977', found: '6546692930373'