This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "grader.h"
int HC(int N){
int left = 1;
int right = N;
Guess(1);
int temp = Guess(N);
bool flag = false;
//false:right
//true : left
while(1){
if (left == right)
return left;
if (temp == 1) {
if (!flag) {//이전에 right수정
left = (left + right) / 2+1;
if (left != right) {
temp = Guess(left);
}
flag = true;
}
else {//이전에 left수정
right = (left + right) / 2;
if (left != right) {
temp = Guess(right);
}
flag = false;
}
}
else if (temp == -1) {
if (!flag) {//이전에 right 수정
right = (left + right) / 2;
if (left != right) {
temp = Guess(left);
temp = Guess(right);
}
flag = false;
}
else {//이전에 left 수정
left = (left + right) / 2 + 1;
if (left != right) {
temp = Guess(right);
temp = Guess(left);
}
flag = true;
}
}
else {
return (left + right) / 2;
}
}
/*for (int i = 1; i <= N; i++) {
int temp = Guess(i);
if (temp == -1) {
return i - 1;
}
}
return N;*/
}
# | 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... |