Submission #59537

#TimeUsernameProblemLanguageResultExecution timeMemory
59537aquablitz11Hotter Colder (IOI10_hottercolder)C++14
89 / 100
849 ms8212 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; Guess(1); int p = 1; while (l < r) { int z = r-l+1; int res, side; if (p == l) { res = Guess(p = r), side = 0; } else if (p == r) { res = Guess(p = l), side = 1; } else if (p < l) { int q = r+(l-p); if (q <= n) { res = Guess(p = q); side = 0; } else { Guess(p = (r <= n/2 ? r : l)); continue; } } else if (p > r) { int q = l-(p-r); if (q >= 1) { res = Guess(p = q); side = 1; } else { Guess(p = (r <= n/2 ? r : l)); continue; } } else { assert(false); } int m = (l+r)/2; if (side == 0) { 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 { 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...