QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#199231 | #6733. Moniphant Sleep | rascalrabbit | WA | 745ms | 32224kb | C++14 | 2.1kb | 2023-10-03 23:40:35 | 2023-10-03 23:40:35 |
Judging History
answer
// what is matter? never mind.
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
inline int read()
{
char c=getchar();int x=0;bool f=0;
for(;!isdigit(c);c=getchar())f^=!(c^45);
for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
if(f)x=-x;return x;
}
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;
#define maxn 400005
#define inf 0x3f3f3f3f
struct node{
int a,b,tagc,c,d,tagd,e;
// -a+b C -c+d D +e
void add(int x){
// assert(x>=0);
e+=x;
}
void sub(int x){
e-=x;
if(tagd&&e<0)tagd=0;
if(e<0)d+=e,e=0;
if(d<0)c+=d,d=0;
}
void C(){
if(tagd){
tagd=e=0;
}
else {
d+=e;
e=0;
if(d<0)c+=d,d=0;
// return;
}
if(tagc)return;
b+=c+d;
c=d=0;
if(b<0)a+=b,b=0;
tagc=1;
}
void D(){
if(!tagd){
d+=e;
e=0;
tagd=1;
}
}
int F(){
return a+b+c+d+e;
}
bool emp(){
return !a&&!b&&!c&&!d&&!e&&!tagc&&!tagd;
}
};
node operator +(node a,node b){
a.sub(-b.a);
a.add(b.b);
if(b.tagc) a.C();
a.sub(-b.c);
a.add(b.d);
if(b.tagd) a.D();
a.add(b.e);
return a;
}
void operator +=(node &a,node b){
a=a+b;
}
node tr[maxn<<2];
void down(int p){
if(!tr[p].emp())
tr[p<<1]+=tr[p],tr[p<<1|1]+=tr[p],tr[p]={0,0,0,0,0,0,0};
}
void mdf(int p,int l,int r,int nl,int nr,node v){
if(l>=nl&&r<=nr)return tr[p]+=v,void();
int mid=l+r>>1; down(p);
if(nl<=mid)mdf(p<<1,l,mid,nl,nr,v);
if(nr>mid)mdf(p<<1|1,mid+1,r,nl,nr,v);
}
int ask(int p,int l,int r,int x){
if(l==r)return tr[p].F();
int mid=l+r>>1; down(p);
if(x<=mid)return ask(p<<1,l,mid,x);
else return ask(p<<1|1,mid+1,r,x);
}
int n,m;
node O[6];
signed main()
{
n=read(),m=read();
tr[1]={0,500000,0,0,0,0,0};
O[1]={0,1,0,0,0,0,0};
O[2]={-1,0,0,0,0,0,0};
O[3]={0,0,0,0,0,1,0};
O[4]={0,0,1,0,0,0,0};
For(_,1,m){
int op=read(),l,r;
if(op<=4) l=read(),r=read(),mdf(1,1,n,l,r,O[op]);
else l=read(),r=read(),cout<<ask(1,1,n,l)<<"\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3356kb
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: 0ms
memory: 3376kb
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: -100
Wrong Answer
time: 745ms
memory: 32224kb
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 499996 500000 499999 500001 499999 499998 499997 499996 499995 499998 500000 500001 500001 499996 499998 499998 499995 499999 500001 499999 500000 500002 500002 499996 500001 499996 499994 499999 500004...
result:
wrong answer 15th numbers differ - expected: '499997', found: '499996'