QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#67864 | #4879. Standard Problem | A_zjzj | WA | 2ms | 5816kb | C++14 | 1.7kb | 2022-12-12 20:30:24 | 2022-12-12 20:30:26 |
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,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 pushadd(int rt,int x){t[rt].x+=x;q[rt]+=x;}
void pushdown(int rt){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){
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);
}
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);}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;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 5748kb
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: 2ms
memory: 5816kb
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 2 1 3 1 2 1 2 1 2 1 3 1 2 1 3 1 3 1 3 1 2 1 3 1 2 1 2 1 0 1 2 1 2 1 2 1 3 1 3 1 3 1 3 1 1 1 1 1 3 1 2 1 2 1 0 1
result:
wrong answer 5th numbers differ - expected: '3', found: '2'