Submission #601260

#TimeUsernameProblemLanguageResultExecution timeMemory
601260SeDunionUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <iostream> #include <algorithm> #include <vector> #include "messy.h" using namespace std; int n; void go(int l, int r) { if (l == r) return; int m = (l + r) >> 1; string cur(n, '1'); for (int i = l ; i <= r ; ++ i) cur[i] = '0'; for (int i = m + 1 ; i <= r ; ++ i) { cur[i] = '1'; //cerr << cur << endl; add_element(cur); cur[i] = '0'; } go(l, m), go(m + 1, r); } #include<assert.h> void go(int l, int r, vector<int>&ans, vector<int>&id) { if (id.size() == 1) { assert(l == r); ans[id[0]] = l; return; } string cur(n, '1'); for (int i : id) cur[i] = '0'; vector<int>bar, jok; for (int i : id) { cur[i] = '1'; if (check_element(cur)) bar.emplace_back(i); else jok.emplace_back(i); cur[i] = '0'; } int m = (l + r) >> 1; go(m + 1, r, ans, bar); go(l, m, ans, jok); } vector<int> restore_permutation(int n_, int w, int r) { n = n_; go(0, n - 1); compile_set(); vector<int>ans(n,-1), id(n); for (int i = 0 ; i < n ; ++ i) id[i] = i; go(0, n - 1, ans, id); 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...