Submission #59531

#TimeUsernameProblemLanguageResultExecution timeMemory
59531aquablitz11Hotter Colder (IOI10_hottercolder)C++14
79 / 100
1191 ms8312 KiB
#include <cassert> #include <random> #include "grader.h" using namespace std; mt19937 rd(31415926); uniform_int_distribution<int> dis(0, 1); int HC(int n) { int l = 1; int r = n; int p = 0; while (l < r) { if (p != l && p != r) { if (dis(rd) == 0) { Guess(l); p = l; } else { Guess(r); p = r; } } int z = r-l+1; int m = (l+r)/2; if (p == l) { int res = Guess(r); p = r; if (z%2 == 0) { if (res == 1) l = m+1; else if (res == -1) r = m; else assert(false); } else { if (res == 1) l = m+1; else if (res == -1) r = m-1; else l = r = m; } } else { int res = Guess(l); p = l; if (z%2 == 0) { if (res == 1) r = m; else if (res == -1) l = m+1; else assert(false); } else { if (res == 1) r = m-1; else if (res == -1) l = m+1; else l = r = m; } } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...