QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#67863 | #4879. Standard Problem | A_zjzj | WA | 3ms | 7864kb | C++14 | 2.1kb | 2022-12-12 20:29:18 | 2022-12-12 20:29:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;using ll=long long;const int N=2e5+10,mod=998244353;const ll INF=1e18;
int T,n,m,p[N<<2],q[N<<2];struct zj{ll x,y;}t[N<<2],ans;
bool operator < (const zj &x,const zj &y){return x.x<y.x;}
zj operator + (const zj &x,const zj &y){return y<x?x:(x<y?y:(zj){x.x,(x.y+y.y)%mod});}
void pushup(int rt){t[rt]=t[rt<<1]+t[rt<<1|1];}
void pushcov(int rt){t[rt]={-INF,0};p[rt]=1;q[rt]=0;}
void pushadd(int rt,int x){t[rt].x+=x;q[rt]+=x;}
void pushdown(int rt){
if(p[rt])pushcov(rt<<1),pushcov(rt<<1|1),p[rt]=0;
if(q[rt])pushadd(rt<<1,q[rt]),pushadd(rt<<1|1,q[rt]),q[rt]=0;
}
void build(int l=1,int r=m,int rt=1){
p[rt]=q[rt]=0;if(l==r)return t[rt]={l==1?0:-INF,l==1?1:0},void();
int mid=(l+r)>>1;build(l,mid,rt<<1);build(mid+1,r,rt<<1|1);pushup(rt);
}
void update(int x,zj y,int l=1,int r=m,int rt=1){
if(l==r){t[rt]=t[rt]+y;return;}int mid=(l+r)>>1;pushdown(rt);
x<=mid?update(x,y,l,mid,rt<<1):update(x,y,mid+1,r,rt<<1|1);pushup(rt);
}
void modify(int L,int R,int x,int l=1,int r=m,int rt=1){
if(L<=l&&r<=R)return pushadd(rt,x);int mid=(l+r)>>1;pushdown(rt);
if(L<=mid)modify(L,R,x,l,mid,rt<<1);if(mid<R)modify(L,R,x,mid+1,r,rt<<1|1);pushup(rt);
}
void cover(int L,int R,int l=1,int r=m,int rt=1){
if(L<=l&&r<=R)return pushcov(rt);int mid=(l+r)>>1;pushdown(rt);
if(L<=mid)cover(L,R,l,mid,rt<<1);if(mid<R)cover(L,R,mid+1,r,rt<<1|1);pushup(rt);
}
zj query(int L,int R,int l=1,int r=m,int rt=1){
if(L<=l&&r<=R)return t[rt];int mid=(l+r)>>1;zj s={-INF,0};pushdown(rt);
if(L<=mid)s=s+query(L,R,l,mid,rt<<1);if(mid<R)s=s+query(L,R,mid+1,r,rt<<1|1);return s;
}
void solve(int l=1,int r=m,int rt=1){
if(l==r){ans=ans+t[rt];return;}int mid=(l+r)>>1;pushdown(rt);solve(l,mid,rt<<1);solve(mid+1,r,rt<<1|1);
}
void get(){
scanf("%d%d",&n,&m);build();for(int i=1,x,y,z;i<=n;i++){
scanf("%d%d%d",&x,&y,&z);zj t;if(x>1){
t=query(1,x-1);if(t.x)update(x,t);cover(1,x-1);
}if(y<m)cover(y+1,m);modify(x,y,z);
}ans={-INF,0};solve();printf("%lld %lld\n",ans.x,ans.y);
}
int main(){
for(scanf("%d",&T);T--;)get();return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 7864kb
input:
2 3 4 1 2 1 2 3 1 2 2 1 2 5 1 4 3 2 5 3
output:
3 1 6 1
result:
ok 4 number(s): "3 1 6 1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 7616kb
input:
30 3 3 1 3 1 1 3 1 1 3 1 3 3 1 2 1 1 3 1 1 3 1 3 3 2 2 1 1 3 1 1 3 1 3 3 1 3 1 1 2 1 1 3 1 3 3 2 3 1 1 2 1 1 3 1 3 3 2 2 1 1 3 1 1 3 1 3 3 2 2 1 1 2 1 1 3 1 3 3 1 3 1 2 3 1 1 3 1 3 3 2 3 1 1 3 1 2 2 1 3 3 1 2 1 1 2 1 1 2 1 3 3 1 3 1 1 3 1 1 3 1 3 3 1 3 1 1 2 1 1 3 1 3 3 2 3 1 1 2 1 1 3 1 3 3 1 3 1 1...
output:
3 1 3 1 -999999999999999997 0 3 1 -999999999999999997 0 -999999999999999997 0 -999999999999999997 0 3 1 -999999999999999997 0 3 1 3 1 3 1 -999999999999999997 0 3 1 -999999999999999998 0 -999999999999999997 0 -999999999999999997 0 -999999999999999997 0 -999999999999999997 0 -999999999999999998 0 3 1 ...
result:
wrong answer 5th numbers differ - expected: '3', found: '-999999999999999997'