QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#421620#1429. Hitgrass8cowCompile Error//C++171.9kb2024-05-25 22:32:582024-05-25 22:32:58

Judging History

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

  • [2024-05-25 22:32:58]
  • 评测
  • [2024-05-25 22:32:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
struct qq{int l,r;}a[101000];
int n,l[101000],r[100100],qc[200100],m;
int F(int x){return lower_bound(qc+1,qc+n+1,x)-qc;}
int nxt[201000],R[201000],sta[201000],le,re,L[200100];
int fo[200100][20];
bool chk(int X){
	le=re=1,sta[1]=n+1;
	//首先n+1肯定是好点. 
	nxt[n+1]=n+1;
	for(int i=0;i<20;i++)fo[n+1][i]=n+1;
	for(int i=n;i>=0;i--){
		while(le<=re&&sta[le]>R[i+1])le++;
		if(le>re){nxt[i]=-1;continue;}
		int nx=sta[le];
		for(int j=19;j>=0;j--)if(((X-1)>>j)&1)nx=fo[nx][j]; 
		//for(int j=1;j<X;j++)nx=nxt[nx]
		if(nx>L[i]){
			fo[i][0]=nxt[i]=sta[le],sta[++re]=i;
			for(int j=1;j<20;j++)fo[i][j]=fo[fo[i][j-1]][j-1];
		}
		else nxt[i]=-1;
		//要求nxt<=R[i+1]
	}
	if(nxt[0]==-1)return 0;
	vector<int>ans;int u=nxt[0];
	while(u<=n)ans.push_back(qc[u]),u=nxt[u]; 
	printf("%d %d ",X,(int)ans.size());
	for(int x:ans)printf("%d ",x);puts("");
	return 1;
}
int vp[201000];
bool fuc,cu;
void sol(){
	n=0;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)scanf("%d%d",&a[i].l,&a[i].r),qc[++n]=a[i].l,qc[++n]=a[i].r;
    if(fuc&&cu){
        printf("?%d ",m);
        for(int i=1;i<=m;i++)printf("%d %d ",a[i].l,a[i].r);
        exit(0);
    }
	sort(qc+1,qc+n+1);n=unique(qc+1,qc+n+1)-qc-1;
	for(int i=1;i<=n+1;i++)R[i]=n+1,L[i]=0;
	for(int i=1;i<=m;i++)a[i].l=F(a[i].l),a[i].r=F(a[i].r),R[a[i].l]=min(R[a[i].l],a[i].r),
	L[a[i].l]=max(L[a[i].l],a[i].r);
	for(int i=n;i;i--)R[i]=min(R[i],R[i+1]);
	for(int i=1;i<=n;i++)L[i]=max(L[i-1],L[i]);
	sort(a+1,a+m+1,[&](qq x,qq y){return x.r<y.r;});
	for(int i=1;i<=n;i++)vp[i]=0;
	int j=0,s1=0;
	for(int i=1;i<=m;i++)if(j<a[i].l)j=a[i].r,vp[j]=1;
	for(int i=1;i<=n;i++)vp[i]+=vp[i-1];
	for(int i=1;i<=m;i++)s1=max(s1,vp[a[i].r]-vp[a[i].l-1]);
	if(s1==1){chk(s1);return;}
    if(fuc&&)
	if(chk(s1-1))return;
	assert(chk(s1));
}
int main(){
	int T;scanf("%d",&T);fuc=(T==18100);
    for(int cas=1;cas<=T;cas++)cu=(cas==8630),sol(); 
	return 0;
}

详细

answer.code: In function ‘void sol()’:
answer.code:57:13: error: expected primary-expression before ‘)’ token
   57 |     if(fuc&&)
      |             ^
answer.code:37:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   37 |         scanf("%d",&m);
      |         ~~~~~^~~~~~~~~
answer.code:38:35: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   38 |         for(int i=1;i<=m;i++)scanf("%d%d",&a[i].l,&a[i].r),qc[++n]=a[i].l,qc[++n]=a[i].r;
      |                              ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:62:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   62 |         int T;scanf("%d",&T);fuc=(T==18100);
      |               ~~~~~^~~~~~~~~