QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#641145 | #5702. Colors | atgc | 0 | 1ms | 3864kb | C++23 | 1.3kb | 2024-10-14 18:51:49 | 2024-10-14 18:51:50 |
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 cur=0;
{
int l=1,r=n;
set<int>qed;
qed.insert(cur);
while(l<r){
int md=(l+r)>>1;
// if(stp^=1)cur+=md;
// else cur-=md;
// deb(cur+md,cur-md);
if(cur+md>n)cur-=md;
else if(cur-md<=0)cur+=md;
else if(qed.count(cur+md))cur-=md;
else cur+=md;
qed.insert(cur);
if(0)r=md;
else l=md+1;
}
cur=1-*qed.begin();
}
int l=1,r=n;
set<int>qed;
qry(cur);qed.insert(cur);
while(l<r){
int md=(l+r)>>1;
// if(stp^=1)cur+=md;
// else cur-=md;
// deb(cur+md,cur-md);
if(cur+md>n)cur-=md;
else if(cur-md<=0)cur+=md;
else if(qed.count(cur+md))cur-=md;
else cur+=md;
qed.insert(cur);
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
Wrong Answer
Test #1:
score: 9
Accepted
time: 1ms
memory: 3860kb
input:
7 0 1 0 0
output:
? 3 ? 7 ? 5 ? 2 = 4
result:
ok OK (4 queries)
Test #2:
score: 9
Accepted
time: 1ms
memory: 3664kb
input:
49 1 0 0 0 1 1 0
output:
? 16 ? 41 ? 4 ? 47 ? 1 ? 46 ? 2 = 45
result:
ok OK (7 queries)
Test #3:
score: 9
Accepted
time: 0ms
memory: 3864kb
input:
10 1 1 1 1 0
output:
? 4 ? 9 ? 6 ? 8 ? 7 = 2
result:
ok OK (5 queries)
Test #4:
score: 9
Accepted
time: 0ms
memory: 3564kb
input:
26 0 1 1 1 1 1
output:
? 10 ? 23 ? 16 ? 20 ? 22 ? 21 = 1
result:
ok OK (6 queries)
Test #5:
score: 9
Accepted
time: 1ms
memory: 3624kb
input:
23 1 1 0 0 0
output:
? 8 ? 20 ? 14 ? 23 ? 12 = 12
result:
ok OK (5 queries)
Test #6:
score: 9
Accepted
time: 0ms
memory: 3576kb
input:
56 1 0 1 1 1 0 0
output:
? 19 ? 47 ? 5 ? 40 ? 8 ? 38 ? 7 = 32
result:
ok OK (7 queries)
Test #7:
score: 9
Accepted
time: 1ms
memory: 3560kb
input:
52 1 0 1 0 0 1 1
output:
? 17 ? 43 ? 4 ? 37 ? 1 ? 39 ? 2 = 37
result:
ok OK (7 queries)
Test #8:
score: 9
Accepted
time: 0ms
memory: 3628kb
input:
43 1 0 0 1 0 0
output:
? 15 ? 37 ? 4 ? 42 ? 6 ? 43 = 38
result:
ok OK (6 queries)
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 3624kb
input:
46 0 0 0 1 0
output:
? 16 ? 39 ? 4 ? 45 ? 7 ? -33
result:
wrong answer Integer parameter [name=k] equals to -33, violates the range [1, 46]
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%