QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#207394 | #6733. Moniphant Sleep | zsc985246 | AC ✓ | 803ms | 63140kb | C++14 | 1.8kb | 2023-10-08 15:01:36 | 2023-10-08 15:01:36 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b) for(ll i=(a);i>=(b);--i)
#define Yes printf("Yes")
#define No printf("No")
#define pb push_back
const ll N=5e5+10;
const ll p=1e9+9;
using namespace std;
struct node{
ll a,b,x,c,d,y,e;
void add(ll k){e+=k;}
void sub(ll k){if(e>=k)e-=k;else{y=0;if(d+e>=k)d+=e-k,e=0;else c+=k-d-e,d=e=0;}}
void tag(){if(!y)d+=e,y=1,e=0;}
void clear(){if(y)e=y=0;else d+=e,e=0;if(!x){x=1;if(b<=c)a+=c-b,b=d,c=d=0;else b+=d-c,c=d=0;}}
ll calc(){return e-a+b-c+d;}
}tr[N<<2];
void operator+=(node &a,node b){
a.sub(b.a),a.add(b.b);
if(b.x)a.clear();
a.sub(b.c),a.add(b.d);
if(b.y)a.tag();
a.add(b.e);
}
ll n,m;
void pushdown(ll rt){
tr[rt<<1]+=tr[rt];
tr[rt<<1|1]+=tr[rt];
tr[rt]={0,0,0,0,0,0,0};
}
void build(ll rt,ll l,ll r){
if(l==r)return void(tr[rt]={0,500000,0,0,0,0,0});
tr[rt]={0,0,0,0,0,0,0};
ll mid=l+r>>1;
build(rt<<1,l,mid);
build(rt<<1|1,mid+1,r);
}
void update(ll rt,ll l,ll r,ll x,ll y,node z){
if(x<=l&&r<=y)return void(tr[rt]+=z);
ll mid=l+r>>1;
pushdown(rt);
if(x<=mid)update(rt<<1,l,mid,x,y,z);
if(y>mid)update(rt<<1|1,mid+1,r,x,y,z);
}
void query(ll rt,ll l,ll r,ll x){
if(l==r)return void(printf("%lld\n",tr[rt].calc()));
ll mid=l+r>>1;
pushdown(rt);
if(x<=mid)query(rt<<1,l,mid,x);
else query(rt<<1|1,mid+1,r,x);
}
void mian(){
scanf("%lld%lld",&n,&m);
build(1,1,n);
while(m--){
ll opt,l,r;
scanf("%lld%lld%lld",&opt,&l,&r);
if(opt==1)update(1,1,n,l,r,{0,1,0,0,0,0,0});
if(opt==2)update(1,1,n,l,r,{1,0,0,0,0,0,0});
if(opt==3)update(1,1,n,l,r,{0,0,0,0,0,1,0});
if(opt==4)update(1,1,n,l,r,{0,0,1,0,0,0,0});
if(opt==5)query(1,1,n,l);
}
}
int main(){
int T=1;
// scanf("%d",&T);
while(T--)mian();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
1 9 1 1 1 1 1 1 1 1 1 3 1 1 2 1 1 1 1 1 1 1 1 4 1 1 5 1 1
output:
500004
result:
ok 1 number(s): "500004"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3608kb
input:
3 7 2 1 3 3 1 3 1 1 3 1 1 3 5 1 1 4 1 3 5 1 1
output:
500001 499999
result:
ok 2 number(s): "500001 499999"
Test #3:
score: 0
Accepted
time: 803ms
memory: 62608kb
input:
500000 500000 2 132991 371170 5 15281 15281 1 278642 397098 2 152103 176573 2 13797 47775 3 139320 370045 3 79054 432340 3 82556 212775 4 270171 469418 5 148000 148000 3 371255 401414 5 71051 71051 2 358945 473071 2 231663 265401 2 20243 58131 1 247710 313373 5 154549 154549 1 17317 233265 5 37602 3...
output:
500000 499999 500000 499998 499999 500000 500000 499997 500000 499997 499997 499999 499998 500000 499997 500000 499999 500001 499999 499999 499997 499997 499996 499998 500000 500001 500001 499996 499998 499999 499996 499999 500001 500000 500000 500002 500002 499997 500001 499997 499995 499999 500004...
result:
ok 99850 numbers
Test #4:
score: 0
Accepted
time: 776ms
memory: 62608kb
input:
500000 500000 1 82261 414004 4 128531 435780 1 182288 357334 1 384377 425512 5 400207 400207 5 12158 12158 4 287819 439382 4 273623 387675 4 141825 285941 3 69773 134995 4 29380 264126 1 294648 422834 5 39538 39538 3 142540 417717 5 234932 234932 3 203802 448531 4 70427 154922 5 350852 350852 1 1512...
output:
500002 500000 500000 500002 500003 500000 499998 499999 500000 500001 499998 499996 500001 499997 499995 499998 499995 499996 499994 499998 499999 500000 499996 499988 499995 499999 499992 500001 499995 499991 499991 499995 500002 499987 499992 500000 500001 499988 499987 499989 499989 499992 500001...
result:
ok 99856 numbers
Test #5:
score: 0
Accepted
time: 780ms
memory: 63140kb
input:
500000 500000 5 72042 72042 3 413594 434238 2 361496 397187 1 269630 487427 3 242649 269514 1 54440 379912 4 186602 218641 3 276439 423353 3 135538 386886 1 18494 105835 2 280844 281961 4 295419 431095 2 371614 462384 3 287902 310870 4 16615 433795 4 190316 318613 3 212017 398069 5 9605 9605 4 91266...
output:
500000 500000 500002 500002 500000 500003 500002 500000 500000 500001 500002 500000 500002 500004 499997 500001 500003 500002 500000 500001 500001 500004 500000 500002 500001 500001 499999 500004 500001 500001 500001 500006 499998 499997 500006 500005 500005 500001 499995 499999 500006 500000 500001...
result:
ok 100105 numbers
Test #6:
score: 0
Accepted
time: 789ms
memory: 62860kb
input:
500000 500000 2 5190 91049 4 128857 445467 3 223530 277888 2 40982 105310 1 407309 471677 2 28575 133349 1 32121 490377 5 253892 253892 3 302998 419525 2 113017 482504 1 69934 143033 4 48272 361234 5 2861 2861 1 73851 222387 4 353590 463398 5 246538 246538 4 172175 241916 3 123903 463282 5 265403 26...
output:
500001 500000 500000 500000 500000 499999 499999 500000 500000 499996 499996 499999 499998 500000 499998 499999 500000 499998 499999 500002 499999 499999 500001 499999 500002 500000 499997 499994 500000 499994 499993 500002 499992 499988 499988 500001 499996 500002 500002 499995 499990 499992 500002...
result:
ok 100018 numbers
Test #7:
score: 0
Accepted
time: 776ms
memory: 61620kb
input:
500000 500000 1 92884 302553 3 55209 426930 4 274477 421174 1 116041 243779 2 184334 487953 3 377378 416732 2 78059 458714 1 117519 134853 5 30966 30966 4 6896 243400 4 133516 387611 5 274315 274315 4 1255 321875 1 223029 472140 1 134662 463400 1 271092 375546 4 154845 453545 2 283001 468220 3 20643...
output:
500000 499999 500000 500000 500002 500003 500000 500003 500000 500000 499996 500001 499994 499999 499996 499994 499995 499995 499999 499998 500001 499992 499990 499990 499990 499990 499998 499997 499996 499991 499991 499994 499998 499997 499990 499990 499997 499996 499990 499995 499991 499991 499993...
result:
ok 100214 numbers
Test #8:
score: 0
Accepted
time: 774ms
memory: 61932kb
input:
500000 500000 5 417190 417190 5 343155 343155 3 238196 397249 2 190674 437636 3 292166 453486 3 33110 230933 1 203367 265293 5 224931 224931 4 147852 361144 5 267505 267505 3 135127 384589 3 223472 441256 1 149972 160456 1 207060 334058 1 461029 486155 1 180058 382221 3 122724 138722 2 438731 448303...
output:
500000 500000 500000 499999 499999 500000 499999 499999 500000 499997 499997 499998 499996 499998 499997 500000 500000 500000 500000 499999 500003 500001 500000 500000 499998 499998 499998 499996 499998 499995 500003 499998 499999 500005 499998 500001 499997 500000 500000 500006 500000 500003 500004...
result:
ok 99758 numbers
Test #9:
score: 0
Accepted
time: 773ms
memory: 61600kb
input:
500000 500000 5 463523 463523 5 113643 113643 2 381674 410504 1 22966 114703 5 16811 16811 5 273752 273752 2 272169 420247 2 71593 112069 4 171364 379367 3 56291 187294 1 151339 169092 1 191063 393959 4 96567 345115 5 47859 47859 2 447869 485334 1 148875 281623 3 57575 88435 3 7881 207243 5 84967 84...
output:
500000 500000 500000 500000 500001 500000 500001 500002 500000 500003 500001 500000 499999 499999 499999 499999 500000 500001 500000 499999 499998 500001 500000 499997 500000 499997 499996 500002 499997 499997 499997 499999 499997 499998 499998 500001 500000 499997 499995 499996 499999 499998 499998...
result:
ok 99487 numbers
Test #10:
score: 0
Accepted
time: 788ms
memory: 61416kb
input:
500000 500000 4 315829 368195 3 414015 486000 2 148601 309648 3 323477 435058 2 7730 312072 1 91960 499853 5 243073 243073 4 308460 375604 1 40395 150056 5 116054 116054 3 142106 406335 3 166868 380856 4 101797 181638 1 31743 237233 4 190434 259395 1 91100 332530 3 156661 282976 5 98708 98708 1 1997...
output:
499999 500001 500003 499999 500003 500001 500001 500001 499999 500001 499999 500002 499999 500007 500002 500004 499998 499999 500006 499999 499999 499997 499997 500001 499997 499994 500002 499997 499998 500002 499996 499999 499998 500000 500001 500002 499997 500000 500003 500005 500003 500002 500003...
result:
ok 99671 numbers
Test #11:
score: 0
Accepted
time: 784ms
memory: 61444kb
input:
500000 500000 2 338729 402306 2 260139 296789 2 348628 378006 4 151959 263061 3 274633 499362 3 132916 136988 3 19132 495822 3 47431 471607 2 144550 199941 3 52929 115332 1 17302 132635 2 195980 480390 3 173564 289435 1 219579 286571 2 319857 387911 1 444872 466260 3 117298 214290 2 245260 322033 1 ...
output:
500003 500000 499999 500001 500003 499999 500005 500000 499999 499999 500005 500000 499996 500001 500001 499998 499999 499996 499998 499998 499993 500002 499993 499997 499998 499998 499998 499992 499993 499997 499997 499993 499994 499995 499988 499996 499989 499992 499994 499997 500001 499999 500000...
result:
ok 99951 numbers
Test #12:
score: 0
Accepted
time: 791ms
memory: 61548kb
input:
500000 500000 4 43080 426035 2 446418 498842 2 261117 446761 3 174657 283077 3 475449 484835 5 346061 346061 2 312006 425604 4 154903 350468 1 53920 374405 2 289214 481287 5 181600 181600 3 72854 222601 5 289827 289827 5 18524 18524 4 304780 417551 1 307684 430391 2 238310 271890 1 196257 364172 5 4...
output:
499999 500001 499999 500000 500000 500002 500003 500001 500003 500003 500005 500005 500002 500006 500004 500003 500000 500004 500002 500007 500000 499999 500000 500002 500001 499998 499998 499998 499999 500001 500002 500000 500000 500003 499998 499999 500003 500001 500001 499999 499997 499999 500000...
result:
ok 100352 numbers