QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641124 | #5702. Colors | atgc | 0 | 0ms | 0kb | C++23 | 956b | 2024-10-14 18:39:15 | 2024-10-14 18:39:19 |
answer
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
const int maxn = 2e5+10;
bool qry(int x){
cout<<"? "<<x<<endl;
bool res;cin>>res;return res;
}
void sol(){
int n;cin>>n;
int len=(n)/2;
int cur=0;int stp=0;
set<int>s;
while(len<n){
s.insert(cur);
if(stp^=1)cur+=len;
else cur-=len;
len=(1+len+n)/2;
}
int dta=*s.begin();
int l=1,r=n;
cur=1-dta;stp=0;
qry(cur);
while(l<r){
int md=(l+r)>>1;
if(stp^=1)cur+=md;
else cur-=md;
if(qry(cur))r=md;
else l=md+1;
}
cout<<"= "<<r<<endl;
}
signed main() {
// ios::sync_with_stdio(0),cin.tie(0);
int T;cin>>T;while(T--)sol();
// const int n=8;
// int len=n / 2;
// int cur=0;int stp=0;
// set<int>se;
// while(len < n){
// deb(len,cur);
// assert(se.insert(cur).second);
// if(stp^=1)cur+=len;
// else cur-=len;
// int nl=(1+len+n)/2;
// len=nl;
// }
// se.insert(cur);
// deb(se,se.size());
}
详细
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 0
Time Limit Exceeded
input:
7
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%