Submission #316075

#TimeUsernameProblemLanguageResultExecution timeMemory
316075MrDominoThe Big Prize (IOI17_prize)C++14
0 / 100
10 ms1528 KiB
#include <bits/stdc++.h>
#include "prize.h"

using namespace std;

mt19937 rng((long long) (new char));

int find_best(int n) {
  /// subtask 1
  vector<int> o;
  for (int i = 0; i < n; i++) {
    o.push_back(i);
  }
  shuffle(o.begin(), o.end(), rng);
  int q = 0;
  int l = 0;
  while (l < n) {
    int r = l, lo = l + 1, hi = n - 1;
    vector<int> v_l = ask(o[l]); q++;
    if (v_l[0] == 0 && v_l[1] == 0) {
      return o[l];
    }
    while (lo <= hi) {
      int pos = (lo + hi) / 2;
      vector<int> v_pos = ask(o[pos]); q++;
      if (v_pos == v_l) {
        r = pos;
        lo = pos + 1;
      } else {
        hi = pos - 1;
      }
    }
    /**if (q >= 9000) {
      while (1) {
        cout << "sad\n";
      }
    }**/
    l = r + 1;
  }
}

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:10:15: warning: control reaches end of non-void function [-Wreturn-type]
   10 |   vector<int> o;
      |               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...