# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
421991 | 2021-06-09T14:29:26 Z | pliam | Hotter Colder (IOI10_hottercolder) | C++14 | 0 ms | 0 KB |
#include "hottercolder.h" #include <bits/stdc++.h> using namespace std; bool check(int x){ Guess(x-1); return (Guess(x)>=0); } int HC(int N){ if(N==1) return 1; int k=1; int logn=log2(N-1); //int hi=N; //int b=1<<logn; //bool needcheck=true; for(int b=(1<<logn);b>0;b>>=1){ if(k+b<=N&&check(k+b)) k+=b; } /* for(int b=(1<<logn);b>0;b>>=1){ if(k+b>N) continue; if(k+b+1>N){ if(check(k+b)) k+=b; continue; } Guess(k+b-1); int tmp=Guess(k+b+1); if(tmp==0) return k+b; else if(tmp>0){ k+=b; continue; } } */ /* while(b>0){ if(k+b>hi){ b>>=1; continue; } if(needcheck) Guess(k); int a=Guess(k+b-1); int m=Guess(k+b); if(m>=0){ k+=b; needcheck=false; b>>=1; } else if(a>0){ k+=b/2; b>>=2; needcheck=true; } else{ hi=k+b/2-1; b>>=2; needcheck=true; } } */ /* //b=2 if(k==N) return k; if(k==N-1){ return check(k+1)?k+1:k; } Guess(k); int tmp=Guess(k+2); if(tmp==0){ return k+1; }else if(tmp==-1){ return k; }else{ if(k==N-2) return k+2; else return (Guess(k+3)>=0)?k+3:k+2; } */ return k; }