Submission #828493

#TimeUsernameProblemLanguageResultExecution timeMemory
828493happypotatoUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
1 ms496 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int, int> #define ff first #define ss second #define pb push_back #include "messy.h" int flog2(int x) { return 31 - __builtin_clz(x); } void AddElements(int n) { string str(n, '0'); for (int i = (n >> 1); i < n; i++) { str[i] = '1'; add_element(str); str[i] = '0'; } for (int bit = flog2(n) - 2; bit >= 0; bit--) { for (int flag = 0; flag < 2; flag++) { for (int i = 0; i < n; i++) { str[i] = (flag ^ bool(i & (1 << (bit + 1))) ? '1' : '0'); } for (int i = 0; i < n; i++) { if (str[i] == '0' && bool(i & (1 << bit))) { str[i] = '1'; add_element(str); str[i] = '0'; } } } } } vector<int> restore_permutation(int n, int w, int r) { AddElements(n); compile_set(); vector<int> ans(n, 0); string cur(n, '0'), sto(n, '0'); int mxbit = flog2(n) - 1; for (int i = 0; i < n; i++) { cur[i] = '1'; if (check_element(cur)) { ans[i] |= (1 << mxbit); sto[i] = '1'; } cur[i] = '0'; } // for (int &x : ans) cerr << x << ' '; cerr << endl; for (int bit = mxbit - 1; bit >= 0; bit--) { cur = sto; for (int i = 0; i < n; i++) sto[i] = '0'; for (int flag = 0; flag < 2; flag++) { for (int i = 0; i < n; i++) { if (cur[i] == '1') continue; cur[i] = '1'; if (check_element(cur)) { ans[i] |= (1 << bit); sto[i] = '1'; } cur[i] = '0'; } for (int i = 0; i < n; i++) { cur[i] = (cur[i] == '0' ? '1' : '0'); } } // for (int &x : ans) cerr << x << ' '; cerr << endl; } 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...