QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#751688#6303. InversionchenyitaooooWA 1ms3960kbC++23854b2024-11-15 20:10:192024-11-15 20:10:26

Judging History

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

  • [2024-11-15 20:10:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3960kb
  • [2024-11-15 20:10:19]
  • 提交

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^F[l][r-1]^F[l+1][r-1];
}
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();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0

output:

? 1 2
:2 2:
? 1 3

result:

wrong output format Unexpected end of file - int32 expected