제출 #895224

#제출 시각아이디문제언어결과실행 시간메모리
895224IrateHotter Colder (IOI10_hottercolder)C++14
53 / 100
431 ms8016 KiB
#include<bits/stdc++.h> using namespace std; int Guess(int n); // int lastG = -1, X; // int cnt = 0; // int Guess(int n){ // cnt++; // // cout << "GUESS: " << lastG << ", " << n << '\n'; // if(lastG == -1 || abs(X - lastG) == abs(X - n)){ // lastG = n; // return 0; // } // if(abs(X - lastG) > abs(X - n)){ // lastG = n; // return 1; // } // lastG = n; // return -1; // } int HC(int n){ int l = 1, r = n, last = 1; Guess(1); while(l < r){ int mid = (l + r) >> 1; // cout << l << ", " << r << ": " << last << '\n'; if(last == l){ int num = Guess(r); last = r; // cout << "NUM: " << num << '\n'; if(num == -1){ if((l + r) % 2)r = mid; else r = mid - 1; last = r; Guess(r); } else if(num == 1){ l = mid + 1; } else{ return (l + r) >> 1; } } else{ int num = Guess(l); last = l; // cout << "NUM: " << num << '\n'; if(num == 1){ if((l + r) % 2)r = mid; else r = mid - 1; } else if(num == -1){ l = mid + 1; last = l; Guess(l); } else return (l + r) >> 1; } } return l; } // int main(){ // for(int i = 1;i <= 500;++i){ // for(int j = 1;j <= i;++j){ // X = j; // cnt = 0; // lastG = -1; // int found_num = HC(i); // if(found_num != j){ // cout << "Wrong Answer: " << i << ", " << j << '\n'; // cout << "FOUND: " << found_num << '\n'; // break; // } // else if(cnt > 18){ // cout << i << ", " << j << ": " << cnt << '\n'; // } // } // } // }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...