Submission #965599

#TimeUsernameProblemLanguageResultExecution timeMemory
965599maomao90Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms768 KiB
// Hallelujah, praise the one who set me free // Hallelujah, death has lost its grip on me // You have broken every chain, There's salvation in your name // Jesus Christ, my living hope #include <bits/stdc++.h> #include "messy.h" using namespace std; #define REP(i, s, e) for (int i = (s); i < (e); i++) #define RREP(i, s, e) for (int i = (s); i >= (e); i--) template <class T> inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;} template <class T> inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;} typedef unsigned long long ull; typedef long long ll; typedef long double ld; #define FI first #define SE second typedef pair<int, int> ii; typedef pair<ll, ll> pll; typedef tuple<int, int, int> iii; #define ALL(_a) _a.begin(), _a.end() #define SZ(_a) (int) _a.size() #define pb push_back typedef vector<int> vi; typedef vector<ll> vll; typedef vector<ii> vii; typedef vector<iii> viii; #ifndef DEBUG #define cerr if (0) cerr #endif const int INF = 1000000005; const ll LINF = 1000000000000000005ll; const int MAXN = 130; int n; vi ans; void encode(int l, int r, int tl, int tr) { int m = l + r >> 1; string s(n, '0'); REP (i, tl, tr) { s[i] = '1'; } REP (i, l, m) { string t = s; t[i] = '1'; add_element(t); } if (l + 1 < r) { encode(l, m, m, r); encode(m, r, l, m); } } void decode(int l, int r, vi vt, vi id) { if (l + 1 == r) { ans[id[0]] = l; return; } int m = l + r >> 1; string s(n, '0'); for (int i : vt) { s[i] = '1'; } vi lv, rv; for (int i : id) { string t = s; t[i] = '1'; if (check_element(t)) { lv.pb(i); } else { rv.pb(i); } } decode(l, m, rv, lv); decode(m, r, lv, rv); } vi restore_permutation(int N, int W, int R) { n = N; encode(0, n, 0, 0); compile_set(); vi id(n); iota(ALL(id), 0); ans = vi(n); decode(0, n, vi(), id); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void encode(int, int, int, int)':
messy.cpp:45:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   45 |     int m = l + r >> 1;
      |             ~~^~~
messy.cpp: In function 'void decode(int, int, vi, vi)':
messy.cpp:64:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |     int m = l + r >> 1;
      |             ~~^~~
#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...