QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#662754#6303. InversionlibantianWA 56ms35184kbC++231.2kb2024-10-21 10:03:092024-10-21 10:03:10

Judging History

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

  • [2024-10-21 10:03:10]
  • 评测
  • 测评结果:WA
  • 用时:56ms
  • 内存:35184kb
  • [2024-10-21 10:03:09]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#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 a[N],pos[N];
int vis[N][N];
int query(int l,int r){
    if (l>=r)  return 0;
	if (~vis[l][r])  return vis[l][r];

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

signed main(){
      int n;
    cin>>n;
    memset(vis,-1,sizeof vis);
    pos[1]=1;
    a[1]=1;
    for(int i=1;i<=n;i++)vis[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(ask(pos[mid],i))res=mid,r=mid-1;
            else l=mid+1;
        }
        for(int j=t;j>=res;j--)pos[j+1]=pos[j];
        pos[res]=i;

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0
0
1
0

output:

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

result:

ok OK, guesses=4

Test #2:

score: -100
Wrong Answer
time: 56ms
memory: 35184kb

input:

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

output:

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

result:

wrong output format Unexpected end of file - int32 expected