QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#735335#6303. Inversiondsbdsb#WA 61ms3672kbC++14701b2024-11-11 19:18:072024-11-11 19:18:08

Judging History

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

  • [2024-11-11 19:18:08]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:3672kb
  • [2024-11-11 19:18:07]
  • 提交

answer

#include<bits/stdc++.h>
#define N 2010
using namespace std;
int n,p[N],sa[N];

bool ch(int x,int l){
	cout<<"? "<<sa[x]<<' '<<l<<endl;
	int a,b;
	cin>>a;
	cout<<"? "<<sa[x]+1<<' '<<l<<endl;
	cin>>b;
	int fz=0;
	for(int i=x+1;i<l;i++) if(p[i]<p[x]) fz^=1;
	if((a+b+fz)%2) return false;
	return true;
}

int main(){
	cin>>n;
	p[1]=1;
	sa[1]=1;
	for(int i=2;i<=n;i++){
		int l=0,r=i-1;
		while(l<r){
			int mid=(l+r+1)/2;
			if(ch(mid,i)) l=mid;
			else r=mid-1;
		}
		for(int j=1;j<=i-1;j++) if(p[j]>l) p[j]++;
		p[i]=l+1;
		memset(sa,0,sizeof sa);
		for(int j=1;j<=i;j++) sa[p[j]]=j;
	}
	cout<<"! ";
	for(int i=1;i<=n;i++) cout<<p[i]<<' ';
	cout<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3672kb

input:

3
0
0
0
1

output:

? 1 2
? 2 2
? 1 3
? 2 3
! 2 3 1 

result:

ok OK, guesses=4

Test #2:

score: -100
Wrong Answer
time: 61ms
memory: 3672kb

input:

1993
0
0
0
0
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
1
1
0
0
1
0
0
1
0
0
1
0
1
1
1
0
0
1
1
1
0
1
1
1
1
1
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
1
0
1
1
0
1
0
1
1
1
1
0
1
0
0
0
0
0
0
1
0
0
1
0
0
0
0
0
0
0
1
1
1
1
0
1
0
1
0
1
0
1
1
0
1
0
0
1
1
1
1
0
1
0
0
0
0
1
0
0
0
0
0
1
1
0
0
1
0
0
1
0
1
1
0
1
1
0
0
1
1
1
0...

output:

? 1 2
? 2 2
? 1 3
? 2 3
? 2 3
? 3 3
? 2 4
? 3 4
? 3 4
? 4 4
? 2 5
? 3 5
? 1 5
? 2 5
? 2 6
? 3 6
? 5 6
? 6 6
? 1 7
? 2 7
? 6 7
? 7 7
? 1 8
? 2 8
? 3 8
? 4 8
? 2 8
? 3 8
? 1 9
? 2 9
? 6 9
? 7 9
? 7 9
? 8 9
? 1 10
? 2 10
? 7 10
? 8 10
? 9 10
? 10 10
? 5 11
? 6 11
? 2 11
? 3 11
? 3 11
? 4 11
? 4 11
? 5 ...

result:

wrong answer Wa.