#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple <ll,ll,ll> plll;
typedef vector <plll> vplll;
typedef pair <ll,ll> pll;
typedef vector <ll> vll;
typedef vector <pll> vpll;
typedef vector <vector <pll>> vvpll;
typedef vector <vector <ll>> vvll;
typedef vector <bool> vb;
typedef vector <vector <bool>> vvb;
#define loop(i, s, e) for (ll i = (s); i < (e); ++i)
#define loopr(i, e, s) for (ll i = (e)-1; i >= (s); --i)
#define all(a) a.begin(), a.end()
const ll inf = 1e9 + 7;
#include "messy.h"
vector<int> restore_permutation(int n, int w, int r) {
int b = 0;
while ((1 << b) < n) ++b;
vector<string> S(b, string(n,'0'));
for (int k = 0; k < b; ++k) {
for (int i = 0; i < n; ++i)
S[k][i] = ((i >> k) & 1) ? '1' : '0';
add_element(S[k]);
}
compile_set();
vector<string> T;
for (int mask = 0; mask < (1 << n); ++mask) {
string t(n,'0');
for (int bit = 0; bit < n; ++bit)
if (mask & (1 << bit))
t[n - 1 - bit] = '1';
if (check_element(t))
T.push_back(t);
}
vector<int> idx(b), p(n);
iota(idx.begin(), idx.end(), 0);
do {
vector<int> cnt(n,0), q(n);
bool ok = true;
for (int j = 0; j < n && ok; ++j) {
int v = 0;
for (int k = 0; k < b; ++k)
if (T[idx[k]][j] == '1')
v |= 1 << k;
if (v < 0 || v >= n || ++cnt[v] > 1) {
ok = false;
break;
}
q[j] = v;
}
if (ok) {
for (int j = 0; j < n; ++j)
p[j] = q[j];
break;
}
} while (next_permutation(idx.begin(), idx.end()));
return p;
}
Compilation message (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... |