Submission #808689

#TimeUsernameProblemLanguageResultExecution timeMemory
808689ono_de206Unscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; #define in insert #define all(x) x.begin(),x.end() #define pb push_back #define eb emplace_back #define ff first #define ss second //#define int long long typedef long long ll; typedef vector<int> vi; typedef set<int> si; typedef multiset<int> msi; typedef pair<int, int> pii; typedef vector<pii> vpii; vector<int> ans; string str; void build(int l, int r) { if(l == r) { return; } int m = (l + r) >> 1; for(int i = l; i <= m; i++) { str[i] = '1'; add_element(str); str[i] = '0'; } for(int i = l; i <= m; i++) { str[i] = '1'; } build(m + 1, r); for(int i = l; i <= m; i++) { str[i] = '0'; } for(int i = m + 1; i <= r; i++) { str[i] = '1'; } build(l, m); } void find(int l, int r, vector<int> a) { if(a.size() != r - l + 1) return; if(l == r) { ans[l] = a[0]; return; } int m = (l + r) >> 1; vector<int> L, R; for(int i = l; i <= r; i++) { int x = a[i - l]; str[x] = '1'; if(check_element(str)) L.pb(x); else R.pb(x); str[x] = '0'; } for(int x : L) { str[x] = '1'; } find(m + 1, r, R); for(int x : L) { str[x] = '0'; } for(int x : R) { str[x] = '1'; } find(l, m, L); } vector<int> restore_permutation(int n, int w, int r) { vector<int> a(n); iota(all(a), 0); ans.resize(n); str = string(n, '0'); build(0, n - 1); compile_set(); str = string(n, '0'); find(0, n - 1, a); vector<int> ans_(n); for(int i = 0; i < n; i++) { ans_[ans[i]] = i; } swap(ans, _ans); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void find(int, int, std::vector<int>)':
messy.cpp:47:14: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |  if(a.size() != r - l + 1) return;
      |     ~~~~~~~~~^~~~~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:86:12: error: '_ans' was not declared in this scope; did you mean 'ans'?
   86 |  swap(ans, _ans);
      |            ^~~~
      |            ans