Submission #802015

#TimeUsernameProblemLanguageResultExecution timeMemory
802015enerelt14Unscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include "messy.h" #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> #define pb push_back using namespace std; vector<int> ans; int N; void go(int l, int r, string s) { if(l == r) return; int mid = (l + r) / 2; for(int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } for(int i = l; i <= mid; i++) { s[i] = '1'; } go(mid + 1, r, s); for(int i = l; i <= r; i++) { s[i] = '1' + '0' - s[i]; } go(l, mid, s); } void find(int l, int r, vector<int> x) { string s(n, '0'); for(int i = 0; i < x.size(); i++) { s[x[i]] = '1'; } if(l == r) { for(int i = 0; i < x.size(); i++) { if(s[i] == '1') continue; ans[i] = l; return; } } vector<int> y, z; for(int i = 0; i < N; i++) { if(s[i] == '1') continue; s[i] = '1'; if(check_element(s)) y.pb(i); else z.pb(i); s[i] = '0'; } int mid = (l + r) / 2; for(int i = 0; i < y.size(); i++) x.pb(y[i]); find(mid + 1, r, x); for(int i = 0; i < y.size(); i++) x.pop_back(); for(int i = 0; i < z.size(); i++) x.pb(z[i]); find(l, mid, x); } vector<int> restore_permutation(int n, int w, int r) { N = n; string s(n, '0'); vector<int> x; go(0, n - 1, s); compile_set(); find(0, n - 1, x); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void find(int, int, std::vector<int>)':
messy.cpp:45:14: error: 'n' was not declared in this scope
   45 |     string s(n, '0');
      |              ^
messy.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < x.size(); i++) {
      |                    ~~^~~~~~~~~~
messy.cpp:50:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |         for(int i = 0; i < x.size(); i++) {
      |                        ~~^~~~~~~~~~
messy.cpp:65:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for(int i = 0; i < y.size(); i++) x.pb(y[i]);
      |                    ~~^~~~~~~~~~
messy.cpp:67:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for(int i = 0; i < y.size(); i++) x.pop_back();
      |                    ~~^~~~~~~~~~
messy.cpp:68:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |     for(int i = 0; i < z.size(); i++) x.pb(z[i]);
      |                    ~~^~~~~~~~~~