Submission #997065

#TimeUsernameProblemLanguageResultExecution timeMemory
997065PromineUnscrambling a Messy Bug (IOI16_messy)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <string> using namespace std; vector<int> restore_permutation(int n, int w, int r) { vector<string> elements; for (int i = 0; i < (1 << n); ++i) { string binary_str = bitset<32>(i).to_string().substr(32 - n); elements.push_back(binary_str); } for (const string& element : elements) { add_element(element); } compile_set(); vector<int> permutation(n, -1); for (int i = 0; i < n; ++i) { string test_element(n, '0'); test_element[i] = '1'; if (check_element(test_element)) { permutation[i] = 0; } else { for (int j = 1; j < n; ++j) { string test_element(n, '0'); test_element[i] = '1'; test_element[(i + j) % n] = '1'; if (check_element(test_element)) { permutation[i] = j; break; } } } } return permutation; } int main() { vector<int> perm = restore_permutation(4, 16, 16); for (int p : perm) { cout << p << " "; } cout << endl; return 0; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:10:29: error: 'bitset' was not declared in this scope
   10 |         string binary_str = bitset<32>(i).to_string().substr(32 - n);
      |                             ^~~~~~
messy.cpp:3:1: note: 'std::bitset' is defined in header '<bitset>'; did you forget to '#include <bitset>'?
    2 | #include <vector>
  +++ |+#include <bitset>
    3 | #include <string>
messy.cpp:10:43: error: request for member 'to_string' in 'i', which is of non-class type 'int'
   10 |         string binary_str = bitset<32>(i).to_string().substr(32 - n);
      |                                           ^~~~~~~~~
messy.cpp:15:9: error: 'add_element' was not declared in this scope; did you mean 'element'?
   15 |         add_element(element);
      |         ^~~~~~~~~~~
      |         element
messy.cpp:18:5: error: 'compile_set' was not declared in this scope
   18 |     compile_set();
      |     ^~~~~~~~~~~
messy.cpp:25:13: error: 'check_element' was not declared in this scope; did you mean 'test_element'?
   25 |         if (check_element(test_element)) {
      |             ^~~~~~~~~~~~~
      |             test_element