#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define arr array
#define vec vector
#define str string
const int N = 140;
int n, lg;
bool on(int x, int i) { return x & (1 << i); }
int flp(int x, int i) { return x ^ (1 << i); }
str prf(int x, int i) {
str ans = "";
for (int j = 0; j <= i; j++) {
if (on(x, j)) ans += "1";
else ans += "0";
}
return ans;
}
void ins(vec<int> x) {
str y = "";
for (int i = 0; i < n; i++) y += "0";
for (int i : x) y[i] = '1';
add_element(y);
}
bool qry(vec<int> x) {
str y = "";
for (int i = 0; i < n; i++) y += "0";
for (int i : x) y[i] = '1';
return check_element(y);
}
void enc() {
for (int i = 0; i < lg; i++) {
for (int x = 0; x < n; x++) {
if (!on(x, i)) continue;
vec<int> in = {x};
if (i != 0) {
str rq = prf(x, i - 1);
rq.back() = (rq.back() == '1') ? '0' : '1';
for (int y = 0; y < n; y++)
if (prf(y, i - 1) == rq) in.push_back(y);
}
ins(in);
}
}
}
arr<int, N> frm;
void dcd() {
for (int i = 0; i < lg; i++) {
for (int x = 0; x < n; x++) {
vec<int> in = {x};
if (i != 0) {
str rq = prf(frm[x], i - 1);
rq.back() = (rq.back() == '1') ? '0' : '1';
for (int y = 0; y < n; y++)
if (prf(frm[y], i - 1) == rq) in.push_back(y);
}
bool rsp = qry(in);
if (rsp) frm[x] = flp(frm[x], i);
}
}
}
vec<signed> restore_permutation(signed _n, signed _w, signed _r) {
n = _n, lg = roundl(log2l(n));
enc();
compile_set();
dcd();
vec<signed> ans;
for (int x = 0; x < n; x++) ans.push_back(frm[x]);
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
messy.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
messy_c.h:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |