QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#613287 | #6394. Turn on the Light | liaoyingyu | WA | 1ms | 3636kb | C++17 | 849b | 2024-10-05 13:52:22 | 2024-10-05 13:52:24 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define pb push_back
const int mod=1e9+7;
const int N=200000+10;
using namespace std;//初始化
typedef pair <int, int> pi;
int n,anss;
void digui(int l,int r,int zhi){
int mid=(l+r)/2;
cout<<"? "<<mid<<endl;
int now,noww;
cin>>now;
if(now==zhi){
anss=mid;
return ;
}
cout<<"? "<<l<<endl;
cin>>noww;
if(now==noww){
anss=l;
return ;
}
else{
if(noww>now){
digui(mid+1,r,noww);
}
else if(noww<now){
digui(l+1,mid,noww);
}
}
return;
}
void solve(){
cin>>n;
digui(1,n,0);
cout<<"! "<<anss<<endl;
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
cout << fixed << setprecision(12);//小数保留位数
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3632kb
input:
3 1 2 2
output:
? 2 ? 1 ? 3 ! 3
result:
ok Correct position at 3
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3636kb
input:
10 1 2 3 4 5 5
output:
? 5 ? 1 ? 8 ? 6 ? 9 ? 9 ! 9
result:
wrong answer Wrong favorite light!