QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#515645#4879. Standard ProblemYoralenWA 1ms7980kbC++141.9kb2024-08-11 20:01:062024-08-11 20:01:07

Judging History

你现在查看的是最新测评结果

  • [2024-08-11 20:01:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7980kb
  • [2024-08-11 20:01:06]
  • 提交

answer

#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
#define int long long
const int N=400005,mod=998244353;
struct Tree{int l,r,ad,max;}tree[N<<2];
int f[N],n,m;
struct node{int l,r,w;}a[N];
map<int,int>mp;
void Pt(int k,int t){tree[k].ad+=t;tree[k].max+=t;}
void Pd(int k){if(tree[k].ad){Pt(k<<1,tree[k].ad);Pt(k<<1|1,tree[k].ad);tree[k].ad=0;}}
void Ph(int k){tree[k].max=max(tree[k<<1].max,tree[k<<1|1].max);}
void Build(int k,int l,int r){
	tree[k].l=l,tree[k].r=r;
	tree[k].ad=tree[k].max=0;
	if(l==r){return;}int mid((l+r)>>1);
	Build(k<<1,l,mid);Build(k<<1|1,mid+1,r);
}
void Addrg(int k,int l,int r,int v){
	if(l>r||l>tree[k].r||r<tree[k].l)return;
	if(l<=tree[k].l&&tree[k].r<=r){Pt(k,v);return;}
	Pd(k);Addrg(k<<1,l,r,v);Addrg(k<<1|1,l,r,v);Ph(k);
}
int Askrg(int k,int l,int r){
	if(l>r||l>tree[k].r||r<tree[k].l)return 0;
	if(l<=tree[k].l&&tree[k].r<=r)return tree[k].max;
	Pd(k);return max(Askrg(k<<1,l,r),Askrg(k<<1|1,l,r));
}
void Mofit(int k,int x,int v){
	if(tree[k].l==tree[k].r){tree[k].max=max(tree[k].max,v);return;}
	int mid=((tree[k].l+tree[k].r)>>1);Pd(k);
	if(x<=mid)Mofit(k<<1,x,v);
	else Mofit(k<<1|1,x,v);Ph(k);
}
signed main(){
	int i,Ti;
	scanf("%lld",&Ti);
	while(Ti--){
		scanf("%lld%lld",&n,&m);Build(1,0,m);
		mp.clear();mp[0]=1;f[0]=0;
		for(i=1;i<=n;i++)f[i]=0;
		int ans=0,res=0;
		for(i=1;i<=n;i++){
			scanf("%lld%lld%lld",&a[i].l,&a[i].r,&a[i].w);
			int val=Askrg(1,0,a[i].l);
			Mofit(1,a[i].l,val+a[i].w);
			Addrg(1,a[i].l+1,a[i].r,a[i].w);
			f[i]=Askrg(1,a[i].l,a[i].r);
			if(f[i]<ans){
				int it=mp[f[i]-a[i].w],jt=mp[f[i]];
				mp[f[i]]=(it+jt)%mod;
			}
			else if(f[i]==ans){
				int it=mp[f[i]-a[i].w],jt=mp[f[i]];
				mp[f[i]]=(it+jt)%mod;
				res=(res+it)%mod;
			}
			else if(f[i]>ans){
				int it=mp[f[i]-a[i].w],jt=mp[f[i]];
				mp[f[i]]=(it+jt)%mod;
				res=(it%mod);ans=f[i];
			}
		}
		printf("%lld %lld\n",ans,res);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 7908kb

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: 0
Accepted
time: 1ms
memory: 7980kb

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
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
2 2
3 1
3 1
3 1
3 1
2 2
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1
3 1

result:

ok 60 numbers

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 7896kb

input:

20
5 5
1 5 1
1 5 1
1 4 1
1 5 1
1 5 1
5 5
2 4 1
1 5 1
1 5 1
2 4 1
2 4 1
5 5
2 4 1
1 5 1
1 5 1
2 5 1
1 3 1
5 5
1 5 1
1 5 1
2 3 1
1 5 1
1 4 1
5 5
1 4 1
1 4 1
2 5 1
1 3 1
2 4 1
5 5
2 4 1
3 3 1
1 3 1
2 4 1
4 4 1
5 5
3 3 1
1 4 1
3 3 1
2 5 1
2 5 1
5 5
2 4 1
2 3 1
4 4 1
2 4 1
2 4 1
5 5
3 3 1
3 3 1
2 4 1
1 4...

output:

5 1
5 1
5 1
5 1
5 1
5 1
5 1
5 1
4 1
5 1
5 1
5 1
5 1
5 1
4 2
5 1
5 1
5 1
5 1
5 1

result:

wrong answer 30th numbers differ - expected: '1', found: '2'