QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#751680#6303. InversionchenyitaooooWA 1ms3788kbC++23831b2024-11-15 20:07:062024-11-15 20:07:07

Judging History

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

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

answer

#include<bits/stdc++.h>
#define Ri register int  
using namespace std;
const int N=2005;
int a[N],F[N][N],b[N],n;
void ff(){
	fflush(stdout);
}
int qy(int l,int r){
	int x,y;
	printf("?%d %d\n",l,r);
	ff();
	scanf("%d",&x);
	if(l==r-1) return x;
	printf("?%d %d\n",l+1,r);
	ff();
	scanf("%d",&y);
	return x^y;
}
int main(){
	scanf("%d",&n);
	a[1]=1;
	for(Ri i=2; i<=n; ++i){
		for(Ri j=1; j<i; ++j){
			b[a[j]]=j;
		}
		int l=1,r=i-1,an=i;
		while(l<=r){
			int mid=(l+r)>>1;
			if(qy(b[mid],i)==1) r=mid-1,an=mid;
			else l=mid+1;
		}
//		printf(":%d %d:\n",i,an);
		for(Ri j=1; j<i; ++j){
			if(a[j]>=an) a[j]++;
		}
		a[i]=an;
		for(Ri j=i-1; j>=1; --j){
			F[j][i]=F[j+1][i]^F[j][i-1]^F[j+1][i-1]^(a[j]>a[i]);
		}
	}
	printf("!");
	for(Ri i=1; i<=n; ++i) printf("%d ",a[i]);
	ff();
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3788kb

input:

3

output:

?1 2

result:

wrong output format Unexpected end of file - int32 expected