Submission #1081107

#TimeUsernameProblemLanguageResultExecution timeMemory
1081107errayUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG 
  #include "/home/ioi/contests/ioi16d2/debug.h"
#else 
  #define debug(...) void(37)
#endif

#include "messy.h"

std::vector<int> restore_permutation(int N, int w, int r) {
    /*
    add_element("0");
    compile_set();
    check_element("0");
    return std::vector<int>();
    */
  {
    vector<vector<int>> sets;
    sets.emplace_back();
    for (int i = 0; i < N; ++i) sets[0].push_back(i);
    for (int l = N; l > 1; l >>= 1) {
      for (int j = 0; j * l < N; ++j) {
        for (int i = j * l + l / 2; i < (j + 1) * l; ++i) {
          string ask(N, '1');
          for (int k = j * l; k < (j + 1) * l; ++k) ask[k] = '0';
          ask[i] = '1'; 
          add_element(ask);
        }
      }
    }

  }
  debug("added");
  compile_set();
  vector<int> ans(N);
  {
    vector<vector<int>> sets;
    sets.emplace_back();
    for (int i = 0; i < N; ++i) sets[0].push_back(i);
    for (int l = N; l > 1; l >>= 1) {
      vector<vector<int>> next;
      for (int j = 0; j * l < N; ++j) {
        array<vector<int>, 2> lr;
        for (auto x : sets[j]) {
          string ask(N, '1');
          for (auto y : sets[j]) ask[y] = '0';
          ask[x] = '1';
          lr[check_element(ask)].push_back(x);  
        }
        next.push_back(lr[0]);
        next.push_back(lr[1]);
      }
      swap(next, sets);
    }
    for (int i = 0; i < N; ++i) ans[sets[i][0]] = i;
  }
  return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...