Submission #373343

#TimeUsernameProblemLanguageResultExecution timeMemory
373343flappybirdUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms620 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; typedef int ll; ll N; ll arr[128]; void add(ll l, ll r) { if (l == r) return; ll i; string s; s.resize(N); for (i = 0; i < N; i++) s[i] = '0'; for (i = 0; i < l; i++) s.replace(s.begin() + i, s.begin() + i + 1, "1"); for (i = r + 1; i < N; i++) s.replace(s.begin() + i, s.begin() + i + 1, "1"); ll mid = (l + r) >> 1; for (i = mid + 1; i <= r; i++) { s.replace(s.begin() + i, s.begin() + i + 1, "1"); add_element(s); s.replace(s.begin() + i, s.begin() + i + 1, "0"); } add(l, mid); add(mid + 1, r); } void check(ll x, ll k) { if (!k) return; ll i; string s; s.resize(N); for (i = 0; i < N; i++) { if (arr[i] == x) s[i] = '0'; else s[i] = '1'; } for (i = 0; i < N; i++) { if (s[i] == '0') { s[i] = '1'; if (check_element(s)) arr[i] += k; s[i] = '0'; } } check(x, k / 2); check(x + k, k / 2); } std::vector<int> restore_permutation(int n, int w, int r) { N = n; add(0, N - 1); compile_set(); check(0, N / 2); vector<ll> res; ll i; res.resize(N); for (i = 0; i < N; i++) { res[i] = arr[i]; } return res; }
#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...