QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#777876 | #6303. Inversion | QBF | WA | 37ms | 3956kb | C++23 | 623b | 2024-11-24 10:36:15 | 2024-11-24 10:36:15 |
Judging History
answer
#include<bits/stdc++.h>
#define ci const int
#define ll long long
using namespace std;
ci N=2005;
int n,rk[N],pos[N];
int qry(ci l,ci r){
if(l==r)return 0;
printf("? %d %d\n",l,r),fflush(stdout);
int x;scanf("%d",&x);
return x;
}
int main(){
scanf("%d",&n);
for(int i=1;i<=n;++i){
int l=0,r=i-1;
while(l!=r){//>=
ci mid=l+r+1>>1;
if(qry(pos[mid],i)==qry(pos[mid]+1,i))l=mid;
else r=mid-1;
}
rk[i]=l+1;
for(int j=1;j<i;++j)if(rk[j]>l)++rk[j];
for(int j=1;j<=i;++j)pos[rk[j]]=j;
}
printf("! ");
for(int i=1;i<=n;++i)printf("%d ",rk[i]);
fflush(stdout);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3956kb
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: 37ms
memory: 3760kb
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.