QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#882798 | #9734. Identify Chord | mhb2010 | Compile Error | / | / | C++14 | 1.0kb | 2025-02-05 11:30:22 | 2025-02-05 11:30:22 |
Judging History
This is the latest submission verdict.
- [2025-02-05 11:30:22]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2025-02-05 11:30:22]
- Submitted
answer
#include<bits/stdc++.h>
using namespace std;
int cas,n,T;
int query(int u,int v){
cout<<"? "<<u+1<<' '<<v+1<<endl;
cin>>x;
return x;
}
void answer(int u,int v,int x=0){
cout<<"! "<<u+1<<' '<<v+1<<endl;
cin>>x;
}
int ad(int x,int f){
return (x+n+f)%n;}
int dec(int x,int f){return (x+n-f)%n;}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>T;
while(T--){
cin>>n;
int u=0,v=n>>1,x;
for(int op=0;(x=query(u,v))==n>>1;op^=1)
if(n&1){
if(op)u=(u+1)%n;
else v=(v+1)%n;
}
else u++,v++;
int lx=query((u-1+n)%n,v),rx=query((u+1)%n,v),w,d;
if(lx>=x&&rx>=x)w=u,d=x-1;
else if(lx<x){
int l=1,r=n>>1;
while(r>l){
int mid=l+r+1>>1;
if(query(dec(u,mid),v)==x-mid)l=mid;
else r=mid-1;
}
w=dec(u,l);d=x-l-1;
}
else{
int l=1,r=n>>1;
while(r>l){
int mid=l+r+1>>1;
if(query(ad(u,mid),v)==x-mid)l=mid;
else r=mid-1;
}
w=ad(u,l);d=x-l-1;
}
if(query(w,ad(v,d))==1)answer(w,ad(v,d));
else answer(w,dec(v,d));
}
return 0;
}
详细
answer.code: In function ‘int query(int, int)’: answer.code:6:14: error: ‘x’ was not declared in this scope 6 | cin>>x; | ^