Submission #743489

#TimeUsernameProblemLanguageResultExecution timeMemory
743489boris_mihovUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include "messy.h" #include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> #include <bitset> #include <random> typedef long long llong; const int MAXN = 256; const int MAXLOG = 8; const int INF = 1e9; std::vector <int> perm; std::vector <int> restore_permutation(int n, int w, int r) { perm.resize(n, 0); std::string element(n, '0'); for (int bit = 0 ; (1 << bit) < n ; ++bit) { for (int i = 0 ; i < n ; ++i) { if (i & (1 << bit)) { if (element[i] == '0') element[i] = '1'; else element[i] = '0'; add_element(element); if (element[i] == '0') element[i] = '1'; else element[i] = '0'; } } for (int i = 0 ; i < n && bit > 0 ; ++i) { if (i & (1 << bit - 1)) { element[i] = '0'; } } for (int i = 0 ; i < n ; ++i) { if (i & (1 << bit)) { element[i] = '1'; } } } compile_set(); std::vector <int> last; std::fill(element.begin(), element.end(), '0'); for (int bit = 0 ; (1 << bit) < n ; ++bit) { std::vector <int> curr; for (int i = 0 ; i < n ; ++i) { if (element[i] == '0') element[i] = '1'; else element[i] = '0'; if (check_element(element)) { perm[i] |= (1 << bit); curr.push_back(i); } if (element[i] == '0') element[i] = '1'; else element[i] = '0'; } for (const int &i : last) { element[i] = '0'; } for (const int &i : curr) { element[i] = '1'; } last = curr; } return perm; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:36:31: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   36 |             if (i & (1 << bit - 1))
      |                           ~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...