Submission #765109

#TimeUsernameProblemLanguageResultExecution timeMemory
765109raysh07Unscrambling a Messy Bug (IOI16_messy)C++17
Compilation error
0 ms0 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; vector <int> p; void build(int l, int r){ if (l == r) return; int m = (l + r)/2; string s; for (int i = 0; i < n; i++){ if (i >= l && i <= r) s += "0"; else s += "1"; } for (int i = l; i <= m; i++){ string st = s; st[i] = "1"; add_element(st); } } void solve(int l, int r, vector<int> curr, vector<int> other){ if (l == r){ p[l] = curr[0]; return; } int m = (l + r)/2; string s; for (int i = 0; i < n; i++) s += "0"; for (auto x : other) s[x] = "1"; vector <int> n1, n2; for (auto x : curr){ string st = s; st[x] = "1"; if (check_element(st)){ n1.push_back(x); } else { n2.push_back(x); } } vector <int> o1 = other; for (auto x : n2) o1.push_back(x); solve(l, m, n1, o1); vector <int> o2 = other; for (auto x : n1) o2.push_back(x); solve(m + 1, r, n2, o2); } vector<int> restore_permutation(int n, int w, int r) { // add_element("0"); // compile_set(); // check_element("0"); // return std::vector<int>(); p.resize(n); build(0, n - 1); compile_set(); vector <int> curr; for (int i = 0; i < n; i++) curr.push_back(i); vector <int> other; solve(0, n - 1, curr, other); vector <int> inv(n); for (int i = 0; i < n; i++) inv[p[i]] = i; return inv; }

Compilation message (stderr)

messy.cpp: In function 'void build(int, int)':
messy.cpp:12:25: error: 'n' was not declared in this scope
   12 |     for (int i = 0; i < n; i++){
      |                         ^
messy.cpp:19:17: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   19 |         st[i] = "1";
      |                 ^~~
      |                 |
      |                 const char*
messy.cpp: In function 'void solve(int, int, std::vector<int>, std::vector<int>)':
messy.cpp:32:25: error: 'n' was not declared in this scope
   32 |     for (int i = 0; i < n; i++) s += "0";
      |                         ^
messy.cpp:33:33: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   33 |     for (auto x : other) s[x] = "1";
      |                                 ^~~
      |                                 |
      |                                 const char*
messy.cpp:39:17: error: invalid conversion from 'const char*' to '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} [-fpermissive]
   39 |         st[x] = "1";
      |                 ^~~
      |                 |
      |                 const char*