#include "grader.h"
int HC(int N){
if(N==1) return 1;
int low = 1;
int high = N;
int flag = 1;
int g = Guess(low);
while ( high - low > 2 ) {
if(flag) g = Guess(high);
else g = Guess(low);
if(g == 1 && flag) {
low = (low + high + 2) / 2;
flag = 0;
} else if (g == -1 && flag) {
high = (low + high - 1) / 2;
g = Guess(low);
flag = 1;
} else if (g == 1 && flag == 0) {
high = (low + high - 1) / 2;
flag = 1;
} else if (g == -1 && flag == 0 ) {
low = (low + high + 2) / 2;
g = Guess(high);
flag = 0;
} else {
return (low + high) / 2;
}
}
if(flag) g = Guess(high);
else g = Guess(low);
if(g == 1 && flag) {
return high;
} else if( g == -1 && flag) {
return low;
} else if (g == 1 && flag == 0) {
return low;
} else if (g == -1 && flag == 0) {
return high;
} else {
return (low + high) /2;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1260 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
1280 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
655 ms |
8288 KB |
Output is partially correct - alpha = 0.120000000000 |