Submission #812119

#TimeUsernameProblemLanguageResultExecution timeMemory
812119becaidoUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx,popcnt,sse4,abm") #include <bits/stdc++.h> #include "messy.h" using namespace std; #define ll long long #define Waimai ios::sync_with_stdio(false), cin.tie(0) #define FOR(x,a,b) for (int x = a, I = b; x <= I; x++) #define pb emplace_back #define F first #define S second vector<int> restore_permutation(int n, int w, int r) { vector<int> p(n, -1); auto ask = [&](auto ask, int l, int r)->void { if (l == r) return; string s(n, '0'); FOR (i, 0, l - 1) s[i] = '1'; FOR (i, r + 1, n - 1) s[i] = '1'; int mid = (l + r) / 2; FOR (i, l, mid) { s[i] = '1'; add_element(s); s[i] = '0'; } ask(ask, l, mid); ask(ask, mid + 1, r); }; ask(ask, 0, n - 1); compile_set(); auto rec = [&](auto rec, int l, int r, vector<int> cand)->void { if (l == r) { p[l] = cand[0]; return; } string s(n, '1'); for (int x : cand) s[x] = '0'; vector<int> nc[2]; for (int x : cand) { s[x] = '1'; nc[!check_element(s)].pb(x); s[x] = '0'; } int mid = (l + r) / 2; rec(rec, l, mid, nc[0]); rec(rec, mid + 1, r, nc[1]); }; vector<int> cand(n), tmp; iota(cand.begin(), cand.end(), 0); rec(rec, 0, n - 1, cand); tmp = p; FOR (i, 0, n - 1) p[tmp[i]] = i; return p; }
#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...