#include <iostream>
#include<vector>
#include<cmath>
#include<set>
#include<algorithm>
#include<random>
#include "messy.h"
using namespace std;
mt19937 rd(time(nullptr));
void comp(string& a, vector<int>& f) {
string b = string(a.size(), '0');
for (int i = 0; i < a.size(); ++i)
b[i] = a[f[i]];
a = b;
}
vector<int> restore_permutation(int n, int w, int r) {
vector<int>f(n), ans(n);
vector<string>s(n, string(n, '0'));
for (int i = 0; i < n; ++i) {
f[i] = i;
for (int j = 0; j <= i; ++j)
s[i][j] = '1';
}
shuffle(begin(f), end(f), rd);
for (int i = 0; i < n; ++i) {
comp(s[i], f);
add_element(s[i]);
}
compile_set();
int ind;
string t = string(n, '0'), g;
g = t;
for (int i = 0; i < n; ++i) {
ind = 0;
for (int j = 0; j < n; ++j) {
if (g[j] == '0' and s[i][j] == '1') {
ind = j;
}
}
g[ind] = '1';
for (int j = 0; j < n; ++j) {
if (t[j] == '0') {
t[j] = '1';
if (check_element(t)) {
ans[j] = ind;
break;
}
t[j] = '0';
}
}
}
return ans;
}
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... |