이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |