Submission #301478

#TimeUsernameProblemLanguageResultExecution timeMemory
301478matheo_apdUnscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count()); int n_; vector<int> ans; void add(int l, int r){ if(l == r) return; string c; for(int i = 0; i < n_; i++){ if(l <= i and i <= r) c.push_back('1'); else c.push_back('0'); } int mid = (l+r)/2; for(int i = l; i <= mid; i++){ c[i] = '0'; add_element(c); c[i] = 1; } add(l, mid); add(mid+1, r); } void solve(int l, int r, vector<int> caras){ if(l == r){ ans[caras[0]] = l; return; } vector<int> L, R; string c; for(int i = 0; i < n; i++){ if(binary_search(caras.begin(), caras.end(), i)) c.push_back('1'); else c.push_back('0'); } for(auto i : caras){ c[i] = '0'; if(check_element(c)) L.push_back(i); else R.push_back(i); c[i] = '1'; } int mid = (l+r)/2; solve(l, mid, L); solve(mid+1, r, R); } vector<int> restore_permutation(int n_, int w, int r){ n = n_; ans.resize(n); add(0, n-1); compile_set(); vector<int> caras; for(int i = 0; i < n; i++) caras.push_back(i); solve(0, n-1, caras); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void solve(int, int, std::vector<int>)':
messy.cpp:29:24: error: 'n' was not declared in this scope
   29 |     for(int i = 0; i < n; i++){
      |                        ^
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:44:5: error: 'n' was not declared in this scope; did you mean 'n_'?
   44 |     n = n_;
      |     ^
      |     n_