This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
vector<vi> devise_strategy(int N) {
  int maxX = 35;
  vector<vi> retvalue(maxX, vi(N+1));
  bool checkB = true;
  int lenInterval = 4096;
  retvalue[0][0] = 0;
  rep(i,1,N+1) {
    retvalue[0][i] = 1 + i / lenInterval;
  }
  int p = 2;
  while(lenInterval != 1) {
    rep(prev,p*2-3,p*2-1) {
      int wasLowInterval = (prev&1) == 0;
      retvalue[prev][0] = checkB;
      rep(resp,1,N+1) {
        int temp = resp % (2*lenInterval);
        int isLowInterval = temp < lenInterval;
        if (wasLowInterval != isLowInterval) {
          // we know the answer
          if (wasLowInterval) {
            // the answer is in the current thing that was opened
            retvalue[prev][resp] = -1-checkB;
          }
          else {
            // the answer is in the opposite of what was opened
            retvalue[prev][resp] = -1-(1-checkB);
          }
          continue;
        }
        temp = resp % lenInterval;
        int newIntervalLen = lenInterval / 2;
        int isHiInterval = temp >= newIntervalLen;
        retvalue[prev][resp] = p*2-1 + isHiInterval;
      }
    }
    p++;
    lenInterval /= 2;
    checkB = !checkB;
  }
  return retvalue;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |