# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997065 | Promine | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}