QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#882675 | #9734. Identify Chord | zqiaor | WA | 1ms | 3712kb | C++17 | 666b | 2025-02-05 10:39:29 | 2025-02-05 10:39:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int T,n,k,d,X,x,y,l,r,mid;
int ask(int x,int y){return cout<<"? "<<(x-1)%n+1<<" "<<(y-1)%n+1<<endl,cin>>X,X;}
void get(int x,int y){cout<<"! "<<(x-1)%n+1<<" "<<(y-1)%n+1<<endl,cin>>X;}
void solve(){
cin>>n,k=n/2,x=1,y=k+1;
while(ask(x,y)==k)if(n%2==0)x++,y++;else (x+k<y?x:y)++;
d=X;
if(ask(x,y+1)==d-1)x+=n,swap(x,y);
l=x,r=y;
while(l<=r){
mid=l+r>>1;
if(ask(x,mid)==d-y+mid)l=mid+1;
else r=mid-1;
}
d=ask(x,l);
if(ask(n+x-d+1,l)==1)get(n+x-d+1,l);
else get(x+d-1,l);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>T;
while(T--)solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3712kb
input:
2 6 2 2 1 0 0 1 -1
output:
? 1 4 ? 1 5 ? 1 2 ? 1 1 ? 1 1 ? 2 1 ! 2 1
result:
wrong answer Wrong answer n=6, actual=2-4, guessed=2-1 (test case 1)