이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int HC(int N){
if ( N == 1 ) {
return 1;
}
if ( N == 2 ) {
Guess(1);
if ( Guess(2) == 1 ) {
return 2;
}
else {
return 1;
}
}
int l = 1, r = N;
int ans = 1, cnt = 0;
while ( l + 1 < r ) {
int md = (l + r) / 2;
if ( md == l + 1 && md == r - 1 ) {
Guess(l);
ans = md;
break;
}
Guess((l + md) / 2);
cnt++;
int y = Guess((md + r) / 2);
ans = (md + r) / 2;
cnt++;
if ( y == 1 ) {
l = md;
}
else if ( y == -1 ) {
r = md;
}
else {
return md;
}
}
if ( l + 1 == r ) {
if ( Guess(l) == 1 ) {
return l;
}
else {
return r;
}
}
ans = (l + r) / 2;
// cout << l << ' ' << ans << ' ' << r << endl;
int x = Guess(r);
if ( x == 1 ) {
return r;
}
else if ( x == -1 ) {
return l;
}
else {
return ans;
}
}
# | 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... |