# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
810321 | ymm | Colors (BOI20_colors) | C++17 | 3057 ms | 256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
set<ll> S;
bool query(ll x)
{
assert(!S.count(x));
S.insert(x);
int d;
printf("? %lld\n", x+1);
fflush(stdout);
scanf("%d", &d);
return d;
}
int main()
{
ll n;
scanf("%lld", &n);
//ll pos = __lg(n-1)+1;
//query(pos);
//ll l = 1, r = n;
//while (l < r) {
// ll m0 = (l+r)/2;
// ll m;
// for (ll i = 0;; ++i) {
// ll dard = i%2? i/2+1: -i/2;
// ll pos2 = pos + m0 + dard;
// if (pos2 < 0 || n <= pos2 || S.count(pos2))
// continue;
// m = m0+dard;
// break;
// }
// if (query(pos + m)) {
// r = m;
// pos = pos + m;
// } else {
// l = m+1;
// while (S.count(pos))
// --pos;
// query(pos);
// }
//}
ll pos = n/3;
query(pos);
ll l = 1, r = n;
int lst = 0;
while (l < r) {
ll m0 = (l+r)/2;
ll x = lst%2? -1: 1;
//cerr << l << ' ' << r << ' ' << pos+1 << ' ' << m0 << '\n';
ll m;
for (ll i = 0;; ++i) {
ll dard = i%2? i/2+1: -i/2;
//ll dard = i%2? -i/2+1: i/2;
ll pos2 = pos + x*(m0+dard);
if (pos2 < 0 || n <= pos2 || S.count(pos2))
continue;
m = m0+dard;
break;
}
if (query(pos = pos + x*m))
r = m;
else
l = m+1;
++lst;
}
printf("= %lld\n", l);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |