QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#782311 | #9634. 序列 | 11d10xy | 0 | 2223ms | 110304kb | C++14 | 2.4kb | 2024-11-25 19:41:37 | 2024-11-25 19:41:41 |
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];
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);
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;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 14068kb
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 525334743947 1074066908082 208925010382 844315637307 1165272250447 2800998439005 2197148394217 2528279260093 2284986853822 4270565725305 1506534732985 62968981524 4567385808376 5533885217691 536965818822 6259134533030 6628852757920 4927647425338 409...
result:
wrong answer 6th lines differ - expected: '348599053983', found: '525334743947'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 242ms
memory: 35156kb
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 134856087810744 124036616357632 51466277782595 120070103325908 14161974050440 68733673603619 11177761154655 202350132291120 269898801142420 217915036590741 205797435989802 312418412906728 376121384894893 437209034210416 227...
result:
wrong answer 2nd lines differ - expected: '30726293751614', found: '30348413052188'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 604ms
memory: 63084kb
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 141891565297515 103782114758488 11850432340486 170864104739867 502696835610127 156432146540106 1003872637397205 2459784243144 90539236926698 228649660745849 967888410179654 354569912391550 613186788422342 567866655535989 392743627822022 1...
result:
wrong answer 1st lines differ - expected: '124830885330445', found: '120076403276258'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 2223ms
memory: 108776kb
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 3871407425219 114134208406 5242854074699 0 6785705675308 4709208693364 1661898020666 7256058957495 953948196511 8141902114603 8739739025092 1430997992257 6775494695954 8650351412296 289938743969 7533296201226 1975376213631 237097672384 8982854104444 100534027229...
result:
wrong answer 6th lines differ - expected: '105147493356021', found: '3791587949092'
Subtask #5:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 1998ms
memory: 106580kb
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 19886917140913 74595959876925 56095979879443 39170979459622 56241493382875 82089508261804 66827291326107 64534604404910 247424364906086 305441066263381 32748265595734 90117587368375 120724851885809 502584107244453 342101835735335 101321215193124 674857896527690 350330073...
result:
wrong answer 1st lines differ - expected: '103621325428465', found: '5561034831143'
Subtask #6:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 2035ms
memory: 110304kb
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 16299848256090 21389779874623 18376587726794 17907751216675 22172991309132 32054411271676 2491356552724 37334870487677 283784212426 1807597044484 44450099158117 844531564174 13886916013697 8206446346249 0 57693335526152 13291326327289 27019296682166 100389977351962 93...
result:
wrong answer 3rd lines differ - expected: '46530827437710', found: '2999709094059'