QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#883095 | #9734. Identify Chord | chrhaa | WA | 11ms | 1664kb | C++14 | 888b | 2025-02-05 14:41:45 | 2025-02-05 14:41:45 |
Judging History
answer
#include<stdio.h>
using namespace std;
#define ll long long
ll T,n,m,f;
inline ll ask(ll x,ll y){
if(f) x=n-x%n,y=n-y%n;
ll z;
printf("? %lld %lld\n",(x-1)%n+1,(y-1)%n+1);
fflush(stdout);
scanf("%lld",&z);
return z;
}
inline ll found(ll x,ll y){
if(f) x=n-x%n,y=n-y%n;
ll z;
printf("! %lld %lld\n",(x-1)%n+1,(y-1)%n+1);
fflush(stdout);
scanf("%lld",&z);
return z;
}
signed main(){
ll x,y,z,l,r,mid;
scanf("%lld",&T);
while(T--){
scanf("%lld",&n);
m=n/2;
x=1;
y=m+1;
while((z=ask(x,y))==m) if(n&1){
if(x+m<y) x++;
else y++;
}else x++,y++;
if(ask(x,y+1)<m){
f=1;
x=n-x;
y=n+n-y;
}
l=x,r=y;
while(l<r){
mid=l+r>>1;
if(ask(x,mid)==z-y+mid) r=mid;
else l=mid+1;
}
z-=y-l+1;
if(ask(n+x-z,l)==1) found(n+x-z,l);
else found(x+z,l);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 1664kb
input:
2 6 2 2 1 2 1 1 4 1 1 1 1 1
output:
? 1 4 ? 1 5 ? 1 6 ? 1 5 ? 2 4 ! 2 4 ? 3 1 ? 3 4 ? 1 4 ? 1 3 ! 1 3
result:
ok ok (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 11ms
memory: 1664kb
input:
1000 15 5 6 4 6 6 1 1 19 8 9 4 6 5 5 1 1 17 8 8 8 8 7 6 4 3 2 2 -1
output:
? 1 8 ? 1 9 ? 1 12 ? 1 10 ? 1 9 ? 5 8 ! 5 8 ? 18 9 ? 18 8 ? 18 14 ? 18 11 ? 18 12 ? 18 13 ? 3 12 ! 3 12 ? 16 8 ? 16 7 ? 15 7 ? 15 6 ? 14 6 ? 14 5 ? 3 16 ? 3 13 ? 3 12 ? 9 11 ! 14 11
result:
wrong answer Wrong answer n=17, actual=3-11, guessed=14-11 (test case 3)