# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1161991 | jmuzhen | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
void restore_permutation(int n, int w, int r, int* result) {
string element0(n, '0');
element0[0] = '1';
add_element(element0);
for (int i = 0; i < n - 1; ++i) {
string element(n, '0');
element[i] = '1';
element[i + 1] = '1';
add_element(element);
}
compile_set();
// find p[0]
for (int j = 0; j < n; ++j) {
string query(n, '0');
query[j] = '1';
if (check_element(query)) {
result[0] = j;
break;
}
}
for (int i = 0; i < n - 1; ++i) {
int prev = result[i];
for (int j = 0; j < n; ++j) {
if (j == prev) continue;
string query(n, '0');
query[prev] = '1';
query[j] = '1';
query[n] = '\0';
if (check_element(query)) {
result[i + 1] = j;
break;
}
}
}
}