QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558429#8672. 排队djh0314Compile Error//C++141.9kb2024-09-11 16:04:512024-09-11 16:04:51

Judging History

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

  • [2024-09-11 16:04:51]
  • 评测
  • [2024-09-11 16:04:51]
  • 提交

answer

#include <bits/stdc++.h>
//#define int long long
using namespace std;
const int N = 1e6+5;
inline int read() {
	int x;
	scanf("%d",&x);
	return x;
}
int n, m,L[N],R[N];
struct Ques {
	int l,r,id;
	friend bool operator < (Ques a,Ques b) {
		return a.r<b.r;
	}
} qu[N];
int ans[N];
struct Tree {
#define ls p<<1
#define rs p<<1|1
	int c[N<<2],tag[N<<2];
	inline void pushup(int p) {
		c[p]=min(c[ls],c[rs]);
	}

	inline void cl(int p,int x) {
		c[p]+=x,tag[p]+=x;
	}

	inline void pushdown(int p) {
		cl(ls,tag[p]),cl(rs,tag[p]);
		tag[p]=0;
	}

	inline void change(int p,int L,int R,int l,int r) {
		if(l<=L && R<=r) {
			c[p]++,tag[p]++;
			return ;
		}
		pushdown(p);
		int mid=L+R>>1;
		if(l<=mid) change(ls,L,mid,l,r);
		if(mid<r)  change(rs,mid+1,R,l,r);
		pushup(p);
	}

	inline int query(int p,int L,int R,int x) {
		if(L==R) return c[p];
		int mid=L+R>>1;
		pushdown(p);
		if(x<=mid) return query(ls,L,mid,x);
		else return query(rs,mid+1,R,x);
	}
	
	inline int find(int p,int L,int R,int x) {
		if(L==R) return L;
		int mid=L+R>>1;
		pushdown(p);
		if(c[ls]<=x) return find(ls,L,mid,x);
		else return find(rs,mid+1,R,x); 
	}
} tr;
inline int FIND(int x) {
	return tr.Find(1,1,n,x);
//	int l=1,r=n,res=n+1;
//	while(l<=r) {
//		int mid=l+r>>1;
////		cout<<l<<" "<<r<<"\n";
//		if(tr.query(1,1,n,mid)<=x) res=mid,r=mid-1;
//		else l=mid+1;
//	}
//	return res;
}
signed main() {
	n=read(),m=read();
	for(int i=1; i<=n; ++i) L[i]=read(),R[i]=read();
	for(int i=1; i<=m; ++i) qu[i].l=read(),qu[i].r=read(),qu[i].id=i;
	sort(qu+1,qu+m+1);
	int now=1;
	for(int i=1; i<=n; ++i) {
		int Lf=FIND(R[i]),Rt=L[i]?FIND(L[i]-1)-1:i;
//		int Lf=tr.Find(1,1,n,R[i]),Rt=L[i]?(tr.Find(1,1,n,L[i]-1)-1):i;
//		Lf=max(Lf,1),Rt=min(Rt,i);
		if(Lf<=Rt) tr.change(1,1,n,Lf,Rt);
		while(now<=m && qu[now].r<=i) ans[qu[now].id]=tr.query(1,1,n,qu[now].l),++now;
	}
	for(int i=1; i<=m; ++i) cout<<ans[i]<<"\n";
	return 0;
}

詳細信息

answer.code: In function ‘int FIND(int)’:
answer.code:64:19: error: ‘struct Tree’ has no member named ‘Find’; did you mean ‘find’?
   64 |         return tr.Find(1,1,n,x);
      |                   ^~~~
      |                   find
answer.code: In function ‘int read()’:
answer.code:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d",&x);
      |         ~~~~~^~~~~~~~~