Submission #230783

#TimeUsernameProblemLanguageResultExecution timeMemory
230783arborUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define lc (i << 1) #define rc (i << 1 | 1) using namespace std; using ll = long long; using pii = pair<int, int>; const int MN = 2e5 + 5, LN = 17, MOD = 1e9 + 7, INF = 0x3f3f3f3f, BSZ = 320; /* void add_element(string x); void compile_set(); bool check_element(string x); */ /* * Inserting the strings in a special way, we can use divide and conquer to restore the permutation. * We can insert them based on the range that each string will conver, if a string covers the range from * [l, r] we first fill [l, r] with 0s (Note that the rest of the string will be 1s to act as placeholders). * Then, for each idx from [l, m] we toggle the bit and insert. Therefore, we can use these strings to find * the indexes that [l, m] map to. Once we have found this range, the elements that were not used correspond * to the other range, [m + 1, r]. We can continue recursing on these to recover the permutation. */ int N, ret[128]; void init(int l, int r) { if (l == r) return; string s(N, '1'); for (int i = l; i <= r; i++) s[i] = '0'; int m = (l + r) / 2; for (int i = l; i <= m; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } init(l, m); init(m + 1, r); } void go(int l, int r, vector<int> cur) { if (l == r) { ret[cur[0]] = l; return; } string s(N, '1'); for (int i : cur) s[i] = '0'; vector<int> left, right; for (int i : cur) { s[i] = '1'; if (check_element(s)) left.push_back(i); else right.push_back(i); s[i] = '0'; } int m = (l + r) / 2; go(l, m, left); go(m + 1, r, right); } int *restore_permutation(int n, int w, int r) { N = n; init(0, N - 1); compile_set(); vector<int> cur; for (int i = 0; i < N; i++) cur.push_back(i); go(0, N - 1, cur); return ret; }

Compilation message (stderr)

messy.cpp: In function 'void init(int, int)':
messy.cpp:35:9: error: 'add_element' was not declared in this scope
         add_element(s);
         ^~~~~~~~~~~
messy.cpp: In function 'void go(int, int, std::vector<int>)':
messy.cpp:52:13: error: 'check_element' was not declared in this scope
         if (check_element(s)) left.push_back(i);
             ^~~~~~~~~~~~~
messy.cpp: In function 'int* restore_permutation(int, int, int)':
messy.cpp:64:5: error: 'compile_set' was not declared in this scope
     compile_set();
     ^~~~~~~~~~~