QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#782394#9634. 序列11d10xy0 2331ms108904kbC++142.4kb2024-11-25 19:58:002024-11-25 19:58:00

Judging History

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

  • [2024-11-25 19:58:00]
  • 评测
  • 测评结果:0
  • 用时:2331ms
  • 内存:108904kb
  • [2024-11-25 19:58:00]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i128=__int128;
int n,m;
namespace ds{
int mx[500010<<2];
i128 len[500010<<2],sum[500010<<2],s0[500010<<2],rs0[500010<<2],tag1[500010<<2],tag2[500010<<2];
i128 dfs1(int u,int l,int r,int x){
   if(l==r)return max(x,mx[u]);
   int mid=l+r>>1;
   if(x>mx[u<<1])return x*len[u<<1]+dfs1(u<<1|1,mid+1,r,x);
   else return dfs1(u<<1,l,mid,x)+rs0[u<<1|1];
}
inline void pushupa(int u,int l,int r){
   int mid=l+r>>1;
   mx[u]=max(mx[u<<1],mx[u<<1|1]);
   rs0[u]=dfs1(u<<1|1,mid+1,r,mx[u<<1]);
   s0[u]=s0[u<<1]+rs0[u];
}
inline void addv(int u,i128 x){
   tag1[u]+=x,sum[u]+=len[u]*x;
}
inline void addm(int u,i128 x){
   tag2[u]+=x,sum[u]+=rs0[u>>1]*x;
}
inline void pushupb(int u){
   sum[u]=sum[u<<1]+sum[u<<1|1]+tag1[u]*len[u]+tag2[u]*rs0[u>>1];
}
void dfs2(int u,int l,int r,int x,i128 w){
   if(l==r)return addv(u,w*max(x,mx[u])),void();
   int mid=l+r>>1;
   if(x>mx[u<<1]){
      addv(u<<1,x*w);
      dfs2(u<<1|1,mid+1,r,x,w);
   }else{
      dfs2(u<<1,l,mid,x,w);
      addm(u<<1|1,w);
   }
   pushupb(u);
}
inline void pushdown(int u,int l,int r){
   addv(u<<1,tag1[u]),addv(u<<1|1,tag1[u]);
   if(u&1)dfs2(u,l,r,mx[u-1],tag2[u]);
   tag1[u]=tag2[u]=0;
}
void mdf(int u,int l,int r,int p,int x){
   if(l==r)return mx[u]=x,void();
   int mid=l+r>>1;pushdown(u,l,r);
   if(p<=mid)mdf(u<<1,l,mid,p,x);
   else mdf(u<<1|1,mid+1,r,p,x);
   pushupa(u,l,r);
}
int opt2(int u,int l,int r,int L,int R,int x){
   if(L<=l&&r<=R){
      dfs2(u,l,r,x,1);
      return max(mx[u],x);
   }
   int mid=l+r>>1;
   if(L<=mid)x=opt2(u<<1,l,mid,L,R,x);
   if(R>mid)x=opt2(u<<1|1,mid+1,r,L,R,x);
   pushupb(u);
   return x;
}
i128 qry(int u,int l,int r,int L,int R){
   if(L<=l&&r<=R)return sum[u];
   int mid=l+r>>1;pushdown(u,l,r);
   i128 res=(L<=mid?qry(u<<1,l,mid,L,R):0)+(R>mid?qry(u<<1|1,mid+1,r,L,R):0);
   pushupb(u);
   return res;
}
void build(int u,int l,int r){
   len[u]=r-l+1;
   if(l==r){
      scanf("%d",&mx[u]),s0[u]=mx[u];
      return;
   }
   int mid=l+r>>1;
   build(u<<1,l,mid),build(u<<1|1,mid+1,r);
   pushupa(u,l,r);
}
}
void wr(i128 x){
   if(x>9)wr(x/10);
   putchar(x%10+'0');
}
int main(){
   scanf("%d%d",&n,&m);
   ds::build(1,1,n);
   for(int op,x,y;m--;){
      scanf("%d%d%d",&op,&x,&y);
      if(op==1)ds::mdf(1,1,n,x,y);
      if(op==2)ds::opt2(1,1,n,x,y,0);
      if(op==3)wr(ds::qry(1,1,n,x,y)),puts("");
   }
   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: 13932kb

input:

1000 1000
200255705 18851142 736009342 406246331 351992319 749189355 944184790 785599293 530084396 616825582 73892135 176401717 973078957 225462579 140426746 324124972 229974996 750749128 879242920 854856469 515750108 662437499 10800517 96488944 534239216 379225718 1241451 150390174 183892560 613018...

output:

115323323048
65823230682
0
47168872319
60782985614
347604982010
918484726470
208925010382
840535955763
1161492568903
2605649492721
2126464657558
2431944278726
2284986853822
4076516323170
1316265012394
62968981524
4470026607416
5281941156796
536965818822
6026443304244
6396161529134
4596377759811
4090...

result:

wrong answer 6th lines differ - expected: '348599053983', found: '347604982010'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 246ms
memory: 35028kb

input:

100000 100000
4637 12023 22485 24887 33065 35780 37538 49402 71281 72891 82706 82752 91276 108256 240372831 135259 144119 527163065 139510686 183411 214260 269767144 246850 265137 200716505 279533 283217 309516 310867 466875375 322790 328304 352577 362081 368658 370430 393854 410075 413844 417924 42...

output:

0
30348413052188
23279151095632
41848082621037
88329797804877
55140674453016
133636709456313
122474896480464
51466277782595
118508383448740
11037534475440
65026328493199
10593855798571
196300700704685
263068509617401
211668650421806
203454856174050
305393649691966
367534901802963
428622551118486
220...

result:

wrong answer 2nd lines differ - expected: '30726293751614', found: '30348413052188'

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 608ms
memory: 62020kb

input:

199996 199998
5015 394604305 13416 39971157 16609 21608 24264 407389425 31670 31976 33151 38949 39093 43561 45026 52355 53865 59168 62183 64166 66110 67179 69567 78899 10409535 393971884 104797 109461 109501 114704 118658 123559 123907 130465 131312 140968 144801 146183 157067 160370 796894425 17818...

output:

120076403276258
158186150928712
21829962212270
96877077820764
138767942333075
100658491794048
11850432340486
170864104739867
448023077335849
156432146540106
986698441368606
2459784243144
90539236926698
228649660745849
961646350335444
337411014751807
608526006770099
525714525469083
380274023300789
16...

result:

wrong answer 1st lines differ - expected: '124830885330445', found: '120076403276258'

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 2331ms
memory: 108832kb

input:

499996 499997
1 2646 3802 4717 7652 9462 10048 15736 15959 17076 21684 21628 25147 26990 26023 28835 33604 34213 36006 39643 38238 40133 45193 44699 47403 48437 51742 53992 57055 56322 61353 61812 62008 67837 66136 70512 72503 72294 75169 77534 81608 80173 85831 85776 87518 89661 93233 93800 96640 9...

output:

0
0
0
0
0
3791587949092
1042999850520
3459583672991
114134208406
4936230030384
0
6304706908811
4427408406828
1618447471498
6368736971589
849592034893
7400682448060
7943456889295
1302909713389
5971959474819
8060227221721
289938743969
6999160825279
2065259750580
228229414886
8350936989945
955744831873...

result:

wrong answer 6th lines differ - expected: '105147493356021', found: '3791587949092'

Subtask #5:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 1990ms
memory: 108832kb

input:

499999 499997
1 913 5858 7110 8076 9893 13142 12135 14769 16455 20711 22647 22330 25867 26677 28695 32280 33608 34824 39255 40515 43887 42090 46155 49082 48316 50861 55535 54485 56506 59203 61928 62076 66600 68030 69805 72680 74796 75455 79690 78235 83297 82398 85367 87069 89711 93646 92554 95923 97...

output:

5561034831143
11722942867462
19663127378387
72599139612795
55805918844557
38869192877563
55767832018226
82328430908704
64645642848213
63558856952173
250329326649027
302423790842314
32748265595734
90617739930283
120718340283357
488145217041494
333323515812115
100806323710315
669591635723130
348012095...

result:

wrong answer 1st lines differ - expected: '103621325428465', found: '5561034831143'

Subtask #6:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 2066ms
memory: 108904kb

input:

500000 499997
811 680 2664 6777 6210 8794 10852 13568 17252 18119 19538 22423 23434 24510 27591 29645 31329 33806 37129 37447 40339 41361 45606 47813 47448 50532 50029 53543 54938 56738 59038 63199 62439 67323 68737 71432 71039 75469 76122 79648 80334 81276 84567 85506 89609 91503 91445 94036 97338 ...

output:

0
0
2999709094059
8092369572135
15871321241876
21371080412407
17962902486082
17452298074350
21045453357625
32607673329107
2491356552724
35992350367545
283784212426
1795584427346
42951508167422
841132827661
13541809670178
8181613757750
0
56906644865150
12679871643037
26066677072074
100451062376499
93...

result:

wrong answer 3rd lines differ - expected: '46530827437710', found: '2999709094059'