QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#782264#9634. 序列11d10xy0 2874ms98432kbC++142.4kb2024-11-25 19:32:522024-11-25 19:33:00

Judging History

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

  • [2024-11-25 19:33:00]
  • 评测
  • 测评结果:0
  • 用时:2874ms
  • 内存:98432kb
  • [2024-11-25 19:32:52]
  • 提交

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];
inline void pushupb(int u){
   sum[u]=sum[u<<1]+sum[u<<1|1];
}
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;
}
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);
   pushupb(u);
}
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 mx[u];
   }
   int mid=l+r>>1;pushdown(u,l,r);
   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);
   return(L<=mid?qry(u<<1,l,mid,L,R):0)+(R>mid?qry(u<<1|1,mid+1,r,L,R):0);
}
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: 2ms
memory: 3784kb

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
34906258695
0
45901243751
60782985614
322753271179
904609811143
206798399223
759623091915
754949617325
1841098030472
1584072063257
1664868356063
1612626838714
2655730035510
812677236705
54931037045
2353408563999
2936605416311
314003708418
3673311872529
3913358951550
2640960749439
271193...

result:

wrong answer 2nd lines differ - expected: '65823230682', found: '34906258695'

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 295ms
memory: 27412kb

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
29936135165075
23269516826526
41600894805629
88153102366973
55115700380363
123745933941494
106135268302344
41674518095031
102490876983193
7877072524840
54332218699011
6700739540705
113640285059518
164256948309193
121278962048051
120601401769363
210933185405256
247021377205842
294014160113132
15214...

result:

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

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 700ms
memory: 50848kb

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:

114508634501015
135217668106756
20050778370639
83417495690193
107468184028587
77204158379210
8735178218208
123885012777108
299398218307915
105479843869625
619738836830622
712200303976
47548197275318
174551075824031
577608596648190
220001909827243
412549958446567
420529329723395
251429611825627
12874...

result:

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

Subtask #4:

score: 0
Wrong Answer

Test #16:

score: 0
Wrong Answer
time: 2031ms
memory: 98432kb

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
2979015137613
114134208406
4051211879960
0
5284974174001
3389609487016
1350006900432
5421419041032
760956513317
6150946500191
6582846707839
1166930960839
4832311145066
6662480635702
289938743969
5838918806104
1930688987925
218288739203
7803251781490
858172730050...

result:

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

Subtask #5:

score: 0
Wrong Answer

Test #19:

score: 0
Wrong Answer
time: 2874ms
memory: 98004kb

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:

4996652226441
12843609492493
18273557954430
71985169578455
76280921083345
46472947029173
87475960739768
104463601988046
91151271748303
74653498725806
321317336263255
373415368970016
43152528239354
95615704946265
201607761739751
689583111380318
484340658016292
125111972518045
961800723530129
46045657...

result:

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

Subtask #6:

score: 0
Wrong Answer

Test #23:

score: 0
Wrong Answer
time: 2252ms
memory: 97996kb

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
9047484364527
15493128842572
19418870461439
15408009914695
14842091102551
17816419353261
27171845190252
2491356552724
35449178494567
283784212426
1780136330203
41095282960403
820059943127
15415251856340
9433269783006
0
55014166727709
12217456755242
27589351802909
101181360659817
92...

result:

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