QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#367042 | #8229. 栈 | WrongAnswer_90 | 0 | 187ms | 23740kb | C++20 | 6.9kb | 2024-03-25 16:26:12 | 2024-03-25 16:26:13 |
Judging History
answer
#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define mp make_pair
//#define LOCALJUDGE
#define int ll
bool ST;
static const ll MOD=1e9+7,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,INF=4557430888798830399;
static const ld eps=1e-11,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
using namespace std;
//#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
struct tup
{
int x,y,z;
tup(int X=0,int Y=0,int Z=0){x=X,y=Y,z=Z;}
inline bool operator <(const tup t1)const{return t1.x+t1.y>x+y;}
};
namespace FastIO
{
template<typename T> inline void write(T x,char ch=' ')
{
if(is_same<char,T>::value)putchar(x);
else
{
if(x<0)x=-x,putchar('-');
static char st[25];int top=0;
do{st[top++]=x%10+'0',x/=10;}while(x);
while(top)putchar(st[--top]);
}
ch!='~'?putchar(ch):0;
}
inline void write(const char*x,char ch=' ')
{
for(int i=0;x[i]!='\0';++i)putchar(x[i]);
ch!='~'?putchar(ch):0;
}
inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
inline void read(char s[])
{
int len=0;char st;
do st=getchar();while(st=='\n'||st==' ');
s[++len]=st,st=getchar();
while(st!='\n'&&st!=' ')s[++len]=st,st=getchar();
s[++len]='\0';
}
template<typename T> inline void read(T &s)
{
s=0;char ch=getchar();
while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
bool tf=(ch=='-')&&(ch=getchar());
while((ch>='0')&&(ch<='9'))s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
s=(tf?-s:s);
}
template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
}
using namespace FastIO;
namespace MTool
{
inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
inline int sqr(int a){return 1ll*a*a%MOD;}
inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
namespace Segment
{
#define ls(x) (t[x].l+t[x].r)
#define rs(x) ((t[x].l+t[x].r)^1)
struct{int l,r,x,v,s;}t[200010];
int ask(int x,int y)
{
if(t[x].l==t[x].r)return t[x].v?t[x].s-t[x].s/t[x].v*y:t[x].s;
if(t[rs(x)].v>=y)return t[x].s-t[rs(x)].s+ask(rs(x),y);
return ask(ls(x),y-t[rs(x)].v+t[rs(x)].x);
}
inline void update(int x)
{
if(t[rs(x)].x>=t[ls(x)].v)
{
t[x].x=t[ls(x)].x+t[rs(x)].x-t[ls(x)].v;
t[x].v=t[rs(x)].v,t[x].s=t[rs(x)].s;
}
else
{
t[x].x=t[ls(x)].x;
t[x].v=t[rs(x)].v+t[ls(x)].v-t[rs(x)].x;
t[x].s=t[rs(x)].s+ask(ls(x),t[rs(x)].x);
}
}
void build(int p,int l,int r)
{
t[p].l=l,t[p].r=r;
if(l==r)return;
int mid=l+((r-l)>>1);
build(ls(p),l,mid),build(rs(p),mid+1,r);
}
void add(int p,int x,int y,int z)
{
if(t[p].l==t[p].r)return t[p].v+=y,t[p].s+=y*z,void();
if(x<=t[ls(p)].r)add(ls(p),x,y,z);
else add(rs(p),x,y,z);
update(p);
}
void del(int p,int x,int y)
{
if(t[p].l==t[p].r)return t[p].x+=y,void();
if(x<=t[ls(p)].r)del(ls(p),x,y);
else del(rs(p),x,y);
update(p);
}
pii query(int x,int y)
{
if(y>=t[x].r)return mp(t[x].x,t[x].v);
if(y<=t[ls(x)].r)return query(ls(x),y);
pii p=query(rs(x),y);
if(p.fi>t[ls(x)].v)return mp(t[ls(x)].x+p.fi-t[ls(x)].v,p.se);
return mp(t[ls(x)].x,t[ls(x)].v-p.fi+p.se);
}
int query2(int p,int x,int&y)
{
int v;
if(x>=t[p].r)
{
if(t[p].l==t[p].r)
{
v=t[p].v?t[p].s-t[p].s/t[p].v*y:t[p].s;
y=max(y-t[p].v,0ll);y+=t[p].x;
return v;
}
if(y<=t[rs(p)].v)
{
v=t[p].s-t[rs(p)].s+query2(rs(p),x,y);
assert(y==0);
return v;
}
y=y-t[rs(p)].v+t[rs(p)].x;
return query2(ls(p),x,y);
}
int s=0;
if(x>t[ls(p)].r)s=query2(rs(p),x,y);
if(!y)s+=t[p].s-t[rs(p)].s;
else s+=query2(ls(p),x,y);
return s;
}
}
using namespace Segment;
int n,m,tot,id[100010],ans[100010];
struct Node{int opt;int id,x,y;Node(int A,int B,int C,int D){opt=A,id=B,x=C,y=D;}};
vector<Node> ve[100010];
inline void mian()
{
read(n,m),build(1,1,m);int opt,x,y,z,tt;
for(int i=1;i<=m;++i)
{
read(opt);
if(opt==1)read(x,y,z,tt),ve[x].eb(Node(1,i,z,tt)),ve[y+1].eb(Node(1,i,-z,tt));
else if(opt==2)read(x,y,z),ve[x].eb(Node(2,i,z,0)),ve[y+1].eb(Node(2,i,-z,0));
else read(x,y,z),ve[x].eb(Node(3,i,y,z)),id[i]=++tot;
}
for(int i=1;i<=n;++i)
{
for(auto p:ve[i])
{
if(p.opt==1)
add(1,p.id,p.x,p.y);
else if(p.opt==2)del(1,p.id,p.x);
else
{
int v=query(1,p.id).se;
p.y=min(p.y,v),p.x=min(p.x,v+1);
p.y=max(0ll,v-p.y),p.x=max(0ll,v-(p.x-1));
ans[id[p.id]]=query2(1,p.id,p.y);
ans[id[p.id]]-=query2(1,p.id,p.x);
}
}
}
for(int i=1;i<=tot;++i)write(ans[i],'\n');
}
}
/*
4 8
1 1 3 3 2
1 2 4 2 1
3 1 2 4
3 2 2 4
2 2 3 1
2 1 2 2
3 1 1 1
3 2 2 3
*/
bool ED;
signed main()
{
#ifdef LOCALJUDGE
freopen("1.in","r",stdin);
freopen("1.out","w",stdout);
#endif
double st=clock();
WrongAnswer_90::mian();
double ed=clock();
#ifndef LOCALJUDGE
cerr<<endl;
#endif
cerr<<"Time: "<<ed-st<<" ms\n";
#ifdef LOCALJUDGE
cerr<<" ";
#endif
cerr<<"Memory: "<<abs(&ST-&ED)/1024.0/1024.0<<" MB\n";
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 8488kb
input:
4907 4910 2 763 3330 1 3 307 1 1 1 2262 3430 22699 89397 1 1915 4000 51541 67587 2 212 2990 9763 2 1086 2162 1 2 1813 4496 16760 1 51 2796 68005 99390 1 1267 1519 74236 66178 3 1768 23808 54314 2 900 4122 27758 3 3287 17350 28989 2 3277 4024 3633 2 444 4866 1 2 353 4219 1061 1 987 3141 99906 17320 2...
output:
0 3032090730 903396180 471569175 200648623 98486697 647114751 123945 50793012 61782451 0 0 0 762429740 321140700 871619914 -748725640 3141098382 0 1792521566 6640518748 2415375780 249435711 225987900 5250788038 1145132507 140071334 0 118545795 -5282465173 511828853 84280112 1232466642 4992966775 283...
result:
wrong answer 17th numbers differ - expected: '536311874', found: '-748725640'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 187ms
memory: 23300kb
input:
99999 99998 1 5026 18575 27178 90423 3 30623 1 1 3 76936 1 1 1 77021 95683 84664 24734 1 46085 74886 40512 11266 3 5048 8594 22468 1 53318 77721 97151 70784 1 70645 91192 37556 13013 1 56752 56940 91812 62887 1 7928 34576 87339 69404 3 74875 32807 100970 3 22338 17221 25771 3 21421 20602 57957 3 717...
output:
0 0 1254619125 5253293000 593473604 2592655824 3657975552 5652513833 110091352 1226646296 1989326852 763582808 8205318671 3018335925 3012598941 20085582585 3242801176 17381308704 24555397019 4722824224 30165705080 899316516 38935050954 988382364 13341823621 14603782283 2449683584 5875277101 80572355...
result:
wrong answer 4th numbers differ - expected: '4366274868', found: '5253293000'
Subtask #3:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 103ms
memory: 23580kb
input:
100000 99993 1 47773 70467 16065 1 2 52349 78446 2304 3 40821 1 1 1 40216 93069 78144 1 1 41089 43671 76025 1 2 35263 68629 31066 3 79881 13534 57327 3 5556 1 1 2 21962 38192 1 1 664 58116 9417 1 3 28089 6039 7989 2 88500 90302 9946 3 63215 49410 60770 2 11069 89527 57581 2 70303 97603 12363 1 3420 ...
output:
0 43794 0 1951 11361 129 898 29245 15938 1947 34972 16405 59952 123666 24537 68209 34537 0 32225 37527 0 31810 16824 96178 14285 300941 57614 1602 114565 61935 4068 114182 17609 152949 26099 179359 250368 4796 183349 125791 17414 114151 42058 0 2698 183297 23029 54464 0 26259 39671 35604 0 0 18437 2...
result:
wrong answer 9th numbers differ - expected: '7969', found: '15938'
Subtask #4:
score: 0
Wrong Answer
Test #17:
score: 0
Wrong Answer
time: 105ms
memory: 23740kb
input:
99999 99996 3 77889 1 10000000000 1 6316 86327 89644 386 3 9260 1 10000000000 2 2603 47234 69717 2 20260 73011 19290 2 62477 81233 26127 1 50140 68508 37004 98794 2 14449 22788 16063 1 43860 84932 50375 21777 1 67345 94584 28202 66610 2 661 68654 1 1 14411 94422 82738 61196 1 16563 94416 4920 38408 ...
output:
0 0 0 0 28808949888 0 0 3073595202 3073595202 4330814124 3073595202 8539315149 0 0 12102121578 10595830206 0 5471959064 6009262398 3073595202 4330814124 4330814124 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1073002500 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1390129564 0 0 0 ...
result:
wrong answer 2nd numbers differ - expected: '34602584', found: '0'
Subtask #5:
score: 0
Skipped
Dependency #1:
0%