# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60870 | spencercompton | Hotter Colder (IOI10_hottercolder) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hottercolder.h"
#include <bits/stdc++.h>
using namespace std;
int HC(int N){
int lo = 1;
int hi = N;
int last = (int)((double)(lo+hi)/3.1);
last = max(last,1);
last = min(last,N);
Guess(last);
while(lo<hi){
int now = hi - (last - lo);
if(now<1 || now>N){
//idea 1
now = (lo+hi)/2;
}
now = max(now,1);
now = min(now,N);
// cout << "!" << lo << " " << hi << " " << last << " " << now << endl;
if(now==last && now-1>=lo){
now--;
}
else if(now==last && now+1<=hi){
now++;
}
else if(now==last){
assert(false);
}
int res = Guess(now);
if(res==0){
// cout << "RETURN 1 " << (now+last)/2 << endl;
return (now+last)/2;
}
int close = last;
int far = now;
if(res==1){
swap(close,far);
}
if(close<far){
int mid = (close+far-1)/2;
hi = mid;
}
else{
int mid = (close+far)/2 + 1;
lo = mid;
}
last = now;
}
// cout << "RETURN 2 " << lo << endl;
return lo;
}