Submission #310206

#TimeUsernameProblemLanguageResultExecution timeMemory
310206lohachoUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms512 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; using LL = long long; const int MOD = (int)1e9 + 7; int N; void push(int s, int e){ if(s == e) return; string in; for(int i = 0; i < N; ++i){ if(i < s || i > e) in += '1'; else in += '0'; } for(int i = s; i <= (s + e) / 2; ++i){ in[i] = '1'; add_element(in); in[i] = '0'; } push(s, (s + e) / 2), push((s + e) / 2 + 1, e); } std::vector<int> restore_permutation(int n, int w, int r) { N = n; push(0, N - 1); compile_set(); vector<vector<int>> now, nxt; vector<int> all; for(int i = 0; i < n; ++i){ all.push_back(i); } now.push_back(all); for(int j = n; j > 1; j >>= 1){ for(int i = 0; i < (int)now.size(); ++i){ vector<int> l, r; string in; for(int x = 0; x < n; ++x){ in += '1'; } for(auto&x:now[i]){ in[x] = '0'; } for(auto&x:now[i]){ in[x] = '1'; if(check_element(in)){ l.push_back(x); } else{ r.push_back(x); } in[x] = '0'; } nxt.push_back(l), nxt.push_back(r); } now = nxt; nxt.clear(); } vector<int> ans(n); for(int i = 0; i < n; ++i){ ans[now[i].front()] = 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...