QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#152310#6303. Inversionchen_zexingWA 88ms3844kbC++17911b2023-08-27 23:54:242023-08-27 23:54:25

Judging History

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

  • [2023-08-27 23:54:25]
  • 评测
  • 测评结果:WA
  • 用时:88ms
  • 内存:3844kb
  • [2023-08-27 23:54:24]
  • 提交

answer

#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int a[2005],p[2005],tot;
int query(int l,int r){
    if(l==r) return 0;
    tot++;
    assert(tot<=40000);
    printf("? %d %d\n",l,r);
    fflush(stdout);
    int t;
    scanf("%d",&t);
    return t;
}
int main() {
    int T = 1, kase = 0;
    //cin >> T;
    while (T--) {
        int n;
        cin>>n;
        a[1]=p[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(query(p[mid],i)!=query(p[mid]+1,i)) r=mid-1;
                else l=mid;
            }
            for(int j=l+1;j<i;j++) a[p[j]]++;
            a[i]=l+1;
            for(int j=1;j<=i;j++) p[a[j]]=j;
        }
        printf("!");
        for(int i=1;i<=n;i++) printf(" %d",a[i]);
        puts("");
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3844kb

input:

3
0
0
1

output:

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

result:

ok OK, guesses=3

Test #2:

score: -100
Wrong Answer
time: 88ms
memory: 3788kb

input:

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

output:

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

result:

wrong answer Wa.