QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662760#6303. InversionlibantianWA 117ms19464kbC++231.2kb2024-10-21 10:07:582024-10-21 10:07:58

Judging History

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

  • [2024-10-21 10:07:58]
  • 评测
  • 测评结果:WA
  • 用时:117ms
  • 内存:19464kb
  • [2024-10-21 10:07:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define fi first
#define se second
#define all(_a) _a.begin(), _a.end()
const int N=2010;
int per[N],ord[N];
int ivs[N][N];
int Query(int l,int r){
    if (l>=r)  return 0;
	if (~ivs[l][r])  return ivs[l][r];

	cout<<"? "<<l<<' '<<r<<endl,fflush(stdout);
	return cin>>ivs[l][r],ivs[l][r];
}
int Compare(int l,int r){
    int num=Query(l,r)^Query(l,r-1)^Query(l+1,r)^Query(l+1,r-1);
    return num;
}

signed main(){
    int n;
    cin>>n;
    memset(ivs,-1,sizeof ivs);
    ord[1]=1;
    per[1]=1;
    for(int i=1;i<=n;i++)ivs[1][1]=0;
    for(int i=2;i<=n;i++){
        int t=i-1,l=1,r=t,res=i;
   
        while(l<=r){
            int mid=l+r>>1;
            if(Compare(ord[mid],i))res=mid,r=mid-1;
            else l=mid+1;
        }
        for(int j=t;j>=res;j--)ord[j+1]=ord[j];
        ord[res]=i;

        for(int j=1;j<=i;j++)per[ord[j]]=j;
        for(int j=t;j;j--)ivs[j][i]=(ivs[j+1][i]^(per[j]>per[i]));
		for (int j=1;j<i;j++)  ivs[j][i]^=ivs[j][i-1];
    }
    cout<<"! ";
    for(int i=1;i<=n;i++)cout<<per[i]<<' ';
    return fflush(stdout),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
0
1

output:

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

result:

ok OK, guesses=4

Test #2:

score: -100
Wrong Answer
time: 117ms
memory: 19464kb

input:

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

output:

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

result:

wrong output format Unexpected end of file - int32 expected