QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782288 | #9634. 序列 | 11d10xy | 0 | 2424ms | 110044kb | C++14 | 2.4kb | 2024-11-25 19:37:15 | 2024-11-25 19:37:26 |
Judging History
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 max(mx[u],x);
}
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: 0ms
memory: 13936kb
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 47168872319 60782985614 324020899747 910573569088 208925010382 752289170817 764698640317 1853914216013 1591184855803 1725899653522 1639417349392 2684304121558 836457232071 50973287148 2300253911804 2923178631057 315075844528 3671367862407 3892387649081 2681063657962 272116...
result:
wrong answer 2nd lines differ - expected: '65823230682', found: '34906258695'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 261ms
memory: 37108kb
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 29962304916788 23267152833076 41625118847124 88184822150245 48891579371766 117528643698579 106064837855654 41672036712813 102532248229508 7878171474019 53551414760742 6700795199144 113984495419986 162788595009324 121368735862869 120295526471440 216700798588649 254420598248331 301440498499100 15181...
result:
wrong answer 2nd lines differ - expected: '30726293751614', found: '29962304916788'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 619ms
memory: 60596kb
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:
114595464373068 129097803310768 7569986896330 81698697304238 107128255241936 75670287774323 8735581548096 137033408057594 314477979638320 103959774244938 603802654237522 712200303976 48766207854295 171489880171249 568450384179382 208613135210656 399854579347581 415437703295799 244070947067668 127190...
result:
wrong answer 1st lines differ - expected: '124830885330445', found: '114595464373068'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 1817ms
memory: 106836kb
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: 2424ms
memory: 108876kb
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: 1962ms
memory: 110044kb
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'