QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863735#6303. InversionGrain_Depot08WA 63ms17408kbC++23876b2025-01-19 21:46:262025-01-19 21:46:27

Judging History

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

  • [2025-01-19 21:46:27]
  • 评测
  • 测评结果:WA
  • 用时:63ms
  • 内存:17408kb
  • [2025-01-19 21:46:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define N 2005
int n,s[N][N],p[N],a[N];
int main(){
    scanf("%d",&n);
    p[1]=a[1]=1;
    for(int i=2;i<=n;++i){
        int l=1,r=i-1,mid,ans=0,w,x;
        while(l<=r){
            mid=(l+r)>>1;
            w=s[p[l]][i-1]^s[p[l]+1][i-1];
            printf("? %d %d\n",p[l],i);fflush(stdout);
            scanf("%d",&x);w^=x;
            printf("? %d %d\n",p[l]+1,i);fflush(stdout);
            scanf("%d",&x);w^=x;
            if(w==0)ans=mid,l=mid+1;
            else r=mid-1;
        }
        for(int j=i;j>ans+1;--j)p[j]=p[j-1];
        p[ans+1]=i;
        for(int j=1;j<=i;++j)a[p[j]]=j;
        for(int j=i-1;j;--j)s[j][i]=s[j+1][i]^s[j][i-1]^s[j+1][i-1]^(a[j]>a[i]);
    }
    printf("! ");
    for(int i=1;i<=n;++i)printf("%d ",a[i]);
    printf("\n");
    fflush(stdout);
    return 0;
}

详细

Test #1:

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

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: 63ms
memory: 17408kb

input:

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

output:

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

result:

wrong answer Wa.