Submission #417861

#TimeUsernameProblemLanguageResultExecution timeMemory
417861yuto1115Unscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
2 ms460 KiB
#include "messy.h" #include <bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < ll(n); i++) #define rep2(i, s, n) for(ll i = ll(s); i < ll(n); i++) #define rrep(i, n) for(ll i = ll(n)-1; i >= 0; i--) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define pb push_back #define eb emplace_back using namespace std; using ll = long long; using P = pair<int, int>; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vp = vector<P>; using vvp = vector<vp>; using vb = vector<bool>; using vvb = vector<vb>; using vs = vector<string>; template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } const int inf = 1001001001; const ll linf = 1001001001001001001; vi restore_permutation(int n, int w, int r) { int log; if (n == 8) log = 3; else if (n == 32) log = 5; else log = 7; rep(i, log) { string s(n, '0'); rep(j, i + 1) s[j] = '1'; add_element(s); } rep2(i, log, n) { rep(j, log) { if (i >> j & 1) { string s(n, '0'); s[i] = '1'; if (j < log - 1) s[j + 1] = '1'; else s[log - 2] = s[log - 1] = '1'; add_element(s); } } } compile_set(); vi pos(log), ans(n, -1); rep(i, log) { rep(j, n) { if (ans[j] >= 0) continue; string s(n, '0'); s[j] = '1'; rep(k, i) s[pos[k]] = '1'; if (check_element(s)) { pos[i] = j; ans[j] = i; break; } } } rep(i, n) { if (ans[i] >= 0) continue; rep(j, log) { string s(n, '0'); s[i] = '1'; if (j < log - 1) s[pos[j + 1]] = '1'; else s[pos[log - 2]] = s[pos[log - 1]] = '1'; if (check_element(s)) { ans[i] += 1 << j; } } } 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...