QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#413186#8672. 排队ANIG#Compile Error//C++141.9kb2024-05-17 09:19:362024-05-17 09:19:38

Judging History

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

  • [2024-05-17 09:19:38]
  • 评测
  • [2024-05-17 09:19:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+5;
int n,m,l[N],r[N],rs[N],f[N];
struct node{
	int l,r,laz,mx,mn;
}p[N<<2];
void upset(int x){
	p[x].mx=max(p[x<<1].mx,p[x<<1|1].mx);
	p[x].mn=min(p[x<<1].mn,p[x<<1|1].mn);
}
void add(int x,int sm){
	p[x].laz+=sm;
	p[x].mx+=sm;
	p[x].mn+=sm;
}
void dnset(int x){
	if(p[x].laz){
		add(x<<1,p[x].laz);
		add(x<<1|1,p[x].laz);
		p[x].laz=0;
	}
}
void add(int x,int l,int r,int sm){
	if(l<=p[x].l&&r>=p[x].r){
		add(x,sm);
		return;
	}
	dnset(x);
	int mid=p[x].l+p[x].r>>1;
	if(l<=mid)add(x<<1,l,r,sm);
	if(r>mid)add(x<<1|1,l,r,sm);
	upset(x);
}
int gets(int x,int d){
	if(p[x].l==p[x].r)return p[x].laz;
	dnset(x);
	if(d<=(p[x].l+p[x].r>>1))return gets(x<<1,d);
	return gets(x<<1|1,d);
}
int gets1(int x,int k,int d){
	if(p[x].l==p[x].r)return p[x].l;
	dnset(x);
	if(d<=(p[x].l+p[x].r>>1))return gets1(x<<1,k,d);
	if(p[x<<1|1].mx>=k)return gets1(x<<1|1,k,d);
	return gets1(x<<1,k,d);
}
int gets2(int x,int k){
	if(p[x].l==p[x].r)return p[x].l;
	dnset(x);
	if(p[x<<1].mn<=k)return gets2(x<<1,k);
	return gets2(x<<1|1,k);
}
void reset(int x,int l,int r){
	p[x].l=l,p[x].r=r;
	if(l==r)return;
	int mid=l+r>>1;
	reset(x<<1,l,mid);
	reset(x<<1|1,mid+1,r);
}
vector<pair<int,int> >g[N];
signed main(){
	cin>>n>>m;
	reset(1,1,n+1);
	for(int i=1;i<=n;i++)cin>>l[i]>>r[i];
	for(int i=1;i<=m;i++){
		int l,r;
		cin>>l>>r;
		g[r].push_back({l,i});
	}
	for(int i=1;i<=n;i++){
		int a=gets2(1,r[i]),b=gets1(1,l[i],i);
		for(int j=1;j<=n;j++)if(gets(1,j)<=r[i]){
			a=j;
			break;
		}
		for(int j=i;j>=1;j--)if(gets(1,j)>=l[i]){
			b=j;
			break;
		}
	//	cout<<a<<"-"<<b<<endl;
	for(int j=a;j<=b;j++)assret(gets(1,j)>=l[i]&&gets(1,j)<=r[i]);
		if(a<=b)add(1,a,b,1);
		for(auto c:g[i]){
			rs[c.second]=gets(1,c.first);
		}
	}
	for(int i=1;i<=m;i++)cout<<rs[i]<<"\n";
}

Details

answer.code: In function ‘int main()’:
answer.code:83:30: error: ‘assret’ was not declared in this scope; did you mean ‘assert’?
   83 |         for(int j=a;j<=b;j++)assret(gets(1,j)>=l[i]&&gets(1,j)<=r[i]);
      |                              ^~~~~~
      |                              assert