#include "bits/extc++.h"
using namespace std;
template <typename T>
void dbgh(const T& t) {
cerr << t << endl;
}
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t << " | ";
dbgh(u...);
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__);
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int((x).size())
void add_element(string x);
bool check_element(string x);
void compile_set();
vector<int> restore_permutation(int n, int, int) {
mt19937 cowng(chrono::steady_clock::now().time_since_epoch().count());
for (int i = 1; i <= n; i++) {
add_element(string(i, '1') + string(n - i, '0'));
}
compile_set();
string cur(n, '0');
vector<int> ans;
for (int i = 0; i < n; i++) {
vector<int> left;
bool vis[n] {};
for (auto& a : ans) {
vis[a] = true;
}
for (int j = 0; j < n; j++) {
if (!vis[j]) {
left.push_back(j);
}
}
shuffle(begin(left), end(left), cowng);
for (auto& a : left) {
cur[a] = '1';
if (check_element(cur)) {
ans.push_back(a);
break;
}
cur[a] = '0';
}
}
vector<int> tmp(n);
for (int i = 0; i < n; i++) {
tmp[ans[i]] = i;
}
return tmp;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 8 |
2 |
Correct |
0 ms |
212 KB |
n = 8 |
3 |
Correct |
0 ms |
212 KB |
n = 8 |
4 |
Correct |
0 ms |
212 KB |
n = 8 |
5 |
Correct |
0 ms |
212 KB |
n = 8 |
6 |
Correct |
0 ms |
212 KB |
n = 8 |
7 |
Correct |
0 ms |
212 KB |
n = 8 |
8 |
Correct |
0 ms |
212 KB |
n = 8 |
9 |
Correct |
0 ms |
212 KB |
n = 8 |
10 |
Correct |
0 ms |
212 KB |
n = 8 |
11 |
Correct |
1 ms |
212 KB |
n = 8 |
12 |
Correct |
0 ms |
212 KB |
n = 8 |
13 |
Correct |
1 ms |
212 KB |
n = 8 |
14 |
Correct |
0 ms |
212 KB |
n = 8 |
15 |
Correct |
0 ms |
212 KB |
n = 8 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 32 |
2 |
Correct |
0 ms |
212 KB |
n = 32 |
3 |
Correct |
0 ms |
212 KB |
n = 32 |
4 |
Correct |
1 ms |
256 KB |
n = 32 |
5 |
Correct |
0 ms |
212 KB |
n = 32 |
6 |
Correct |
0 ms |
212 KB |
n = 32 |
7 |
Correct |
1 ms |
212 KB |
n = 32 |
8 |
Correct |
0 ms |
212 KB |
n = 32 |
9 |
Correct |
1 ms |
212 KB |
n = 32 |
10 |
Correct |
0 ms |
212 KB |
n = 32 |
11 |
Correct |
1 ms |
212 KB |
n = 32 |
12 |
Correct |
0 ms |
212 KB |
n = 32 |
13 |
Correct |
0 ms |
212 KB |
n = 32 |
14 |
Correct |
1 ms |
212 KB |
n = 32 |
15 |
Correct |
0 ms |
212 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
n = 32 |
2 |
Correct |
0 ms |
212 KB |
n = 32 |
3 |
Correct |
0 ms |
212 KB |
n = 32 |
4 |
Correct |
0 ms |
212 KB |
n = 32 |
5 |
Incorrect |
1 ms |
212 KB |
grader returned WA |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |