QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#782258 | #9634. 序列 | 11d10xy | 0 | 2277ms | 108880kb | C++14 | 2.4kb | 2024-11-25 19:31:53 | 2024-11-25 19:31:53 |
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]);
}
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: 3ms
memory: 13892kb
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 374449933235 906485559662 206798399223 1224673756334 2120847012234 3404004472973 3681006247407 4028060494248 5485027330224 14136793588232 2353680514206 150893226473 16594957528790 17581696560680 6191899489639 19141078724140 19238269621939 2380149470...
result:
wrong answer 2nd lines differ - expected: '65823230682', found: '34906258695'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 248ms
memory: 40048kb
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 96793552545261 55115700380363 147466795736412 120638490364442 54172276395031 130933775232665 11687656340156 128532909457107 67079909439665 333651135919879 373419869171363 253595619931083 210007276793666 1102299438443273 1126851292906158 1283489568553325...
result:
wrong answer 2nd lines differ - expected: '30726293751614', found: '29936135165075'
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 621ms
memory: 61684kb
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 22612109049211 126041724829453 151721842409877 140325658003452 16929725229120 762932720440432 870423859884112 359615598504172 2946946132844689 3924404026186 87298056066152 675790921703140 2818618819199111 2994207498645003 2576633481040232 2104690933946570 329452091435...
result:
wrong answer 1st lines differ - expected: '124830885330445', found: '114508634501015'
Subtask #4:
score: 0
Wrong Answer
Test #16:
score: 0
Wrong Answer
time: 1778ms
memory: 108880kb
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 4239912198212 228268416812 7737326348225 0 8851243937068 5834635845154 4424825496322 13118366960924 4536265619870 18153739645621 19196166209606 12367328658207 19531160018694 23841310359659 289938743969 20640703594318 5531640057172 834770253226 16422047746710 140...
result:
wrong answer 6th lines differ - expected: '105147493356021', found: '3791587949092'
Subtask #5:
score: 0
Wrong Answer
Test #19:
score: 0
Wrong Answer
time: 2277ms
memory: 108880kb
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 16588797872111 40805342235434 133638495420955 391340910971696 269499595936248 790903171449718 905079686061576 867404734540270 6605932572686582 18799858283327848 19467910893106834 271485749108640 1305162558198160 1193189341256285 32566501437196019 30081328740673415 5087582914691757 3983...
result:
wrong answer 1st lines differ - expected: '103621325428465', found: '4996652226441'
Subtask #6:
score: 0
Wrong Answer
Test #23:
score: 0
Wrong Answer
time: 1862ms
memory: 107324kb
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 11290980007349 20960288304825 25179576765906 21383869149680 21719125524463 23649350061666 35215451417267 10949729220819 92349680879514 283784212426 3926451771791 98553622966589 820059943127 67807001087700 11352296035840 0 217020644716235 63466310734217 170344382299475 4960777802536...
result:
wrong answer 3rd lines differ - expected: '46530827437710', found: '2999709094059'