QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#489417#8819. CNOI KnowledgeEdwin_VanCleefWA 37ms3948kbC++14692b2024-07-24 20:02:082024-07-24 20:02:08

Judging History

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

  • [2024-07-24 20:02:08]
  • 评测
  • 测评结果:WA
  • 用时:37ms
  • 内存:3948kb
  • [2024-07-24 20:02:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int n,cnt=1,a[maxn];
int query(int x,int y){
    printf("? %d %d\n",x,y);
    fflush(stdout);
    int res;
    scanf("%d",&res);
    return res;
}
int main(){
    scanf("%d",&n);
    a[1]=1;
    for(int i=2;i<=n;i++){
        int l=1,r=i-1,ans=0;
        while(l<=r){
            int mid=(l+r)>>1;
            if(query(mid,i-1)+i-mid+1!=query(mid,i)){
                ans=mid;
                l=mid+1;
            }
            else r=mid-1;
        }
        if(!ans) a[i]=++cnt;
        else a[i]=a[ans];
    }
    cout<<"! ";
    for(int i=1;i<=n;i++) printf("%d ",a[i]);
    fflush(stdout);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

12
1
3
3
6
3
6
6
10
6
10
10
15
6
10
15
21
10
15
21
27
15
20
10
14
3
6
6
9
14
20
26
34
34
43
14
19
6
9
3
5
1
2
19
25
5
8
2
5
19
25
5
9
13
19

output:

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

result:

ok Accepted. 54 queries used.

Test #2:

score: -100
Wrong Answer
time: 37ms
memory: 3948kb

input:

1000
1
3
3
5
1
2
2
3
1
2
3
7
7
11
5
8
3
5
1
2
8
11
2
3
1
2
7
11
2
5
3
7
11
15
5
8
3
5
1
3
11
15
5
8
3
5
1
2
15
19
5
7
2
3
1
2
15
19
3
4
2
3
1
2
19
23
4
5
2
3
1
2
17
20
4
5
2
3
1
2
20
23
4
5
2
3
1
2
15
23
4
9
6
13
7
15
23
31
9
14
5
8
3
5
1
3
23
31
11
15
5
7
3
5
1
3
31
41
11
16
5
8
3
5
1
2
36
45
11
15...

output:

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

result:

wrong answer Too many queries.