#include "grader.h"
#include<iostream>
int HC(int n){
if (n == 1)
return 1;
int l, r, mid = (n + 1) / 2, pre = mid + 1;
Guess(mid);
if (Guess(mid + 1) == 1)
l = mid + 1, r = n;
else
l = 1, r = mid;
while (l < r){
//std::cerr << l << ' ' << r << ' ' << pre << std::endl;
mid = (l + r + (pre <= l)) >> 1;
int nxt = 2 * mid - pre;
if (nxt < 1)
nxt = 1;
if (nxt > n)
nxt = n;
mid = (pre + nxt) / 2;
int d = ((pre + nxt) % 2 == 0);
//std::cerr << mid << ' ' << nxt << ' ' << d << std::endl;
int x = Guess(nxt);
if (x == 0)
return mid;
if (pre < nxt){
if (x == 1)
l = mid + d;
else
r = mid - d;
} else {
if (x == 1)
r = mid - d;
else
l = mid + d;
}
pre = nxt;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
23 ms |
1292 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
22 ms |
1228 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
736 ms |
8100 KB |
Output is partially correct - alpha = 0.250000000000 |