Submission #1126352

#TimeUsernameProblemLanguageResultExecution timeMemory
1126352I_love_BanuUnscrambling a Messy Bug (IOI16_messy)C++20
100 / 100
2 ms584 KiB
#include"bits/stdc++.h" #include"messy.h" using namespace std; int N; void gen(int l, int r) { if (l < r) { string s(N, '0'); for (int i = 0; i < l; i ++) { s[i] = '1'; } for (int i = r + 1; i < N; i ++) { s[i] = '1'; } int mi = (l + r) / 2; for (int i = l; i <= mi; i ++) { s[i] = '1'; add_element(s); s[i] = '0'; } gen(l, mi); gen(mi + 1, r); } } const int mxN = 128; using vi = vector<int>; using si = set<int>; si fine; si ban; vi ans; void revert(si& tmp) { for (int i : fine) { ban.insert(i); } for (int i : tmp) { ban.erase(i); } fine.clear(); for (int i : tmp) { fine.insert(i); } } void go(int l, int r) { if (l == r) { ans[*begin(fine)] = l; } else if (l < r) { string S(N, '0'); for (int i : ban) { S[i] = '1'; } si tmp; for (int i : fine) { S[i] = '1'; if (!check_element(S)) { ban.insert(i); tmp.insert(i); } S[i] = '0'; } for (int i : ban) { fine.erase(i); } int mi = (l + r) / 2; go(l, mi); revert(tmp); go(mi + 1, r); } } vector<int> restore_permutation(int n, int w, int r) { N = n; gen(0, N - 1); compile_set(); for (int i = 0; i < N; i ++) { fine.insert(i); } ans.assign(N, 0); go(0, N - 1); return ans; }

Compilation message (stderr)

messy.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
messy_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...