#include "messy.h"
//#include "grader.cpp"
#include <set>
#include <vector>
#include <iostream>
using namespace std;
vector <int> ansPerm;
void gen(int l, int r, int n)
{
if(l==r) return;
string curr = "";
for(int i = 0;i<n;i++)
{
if(i>=l && i<=r) curr += "0";
else curr += "1";
}
for(int i = l;i<=(l+r)/2;i++)
{
curr[i] = '1';
add_element(curr);
curr[i] = '0';
}
gen(l, (l+r)/2, n);
gen((l+r)/2+1, r, n);
}
void solve(int l, int r, set <int> s, int n)
{
if(l==r)
{
ansPerm[*s.begin()] = l;
return;
}
set <int> lhs, rhs;
for(int x: s)
{
string curr = "";
for(int i = 0;i<n;i++)
{
if(s.count(i)==false) curr += "1";
else
{
if(i==x) curr += "1";
else curr += "0";
}
}
if(check_element(curr)==true) lhs.insert(x);
else rhs.insert(x);
}
solve(l, (l+r)/2, lhs, n);
solve((l+r)/2+1, r, rhs, n);
}
vector<int> restore_permutation(int n, int w, int r)
{
gen(0, n-1, n);
compile_set();
ansPerm.resize(n);
set <int> s;
for(int i = 0;i<n;i++) s.insert(i);
solve(0, n-1, s, n);
return ansPerm;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
n = 8 |
2 |
Correct |
0 ms |
384 KB |
n = 8 |
3 |
Correct |
1 ms |
384 KB |
n = 8 |
4 |
Correct |
1 ms |
384 KB |
n = 8 |
5 |
Correct |
1 ms |
256 KB |
n = 8 |
6 |
Correct |
1 ms |
256 KB |
n = 8 |
7 |
Correct |
1 ms |
256 KB |
n = 8 |
8 |
Correct |
0 ms |
256 KB |
n = 8 |
9 |
Correct |
1 ms |
368 KB |
n = 8 |
10 |
Correct |
1 ms |
256 KB |
n = 8 |
11 |
Correct |
0 ms |
256 KB |
n = 8 |
12 |
Correct |
1 ms |
256 KB |
n = 8 |
13 |
Correct |
0 ms |
256 KB |
n = 8 |
14 |
Correct |
1 ms |
256 KB |
n = 8 |
15 |
Correct |
0 ms |
256 KB |
n = 8 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 32 |
2 |
Correct |
1 ms |
384 KB |
n = 32 |
3 |
Correct |
1 ms |
384 KB |
n = 32 |
4 |
Correct |
1 ms |
384 KB |
n = 32 |
5 |
Correct |
1 ms |
372 KB |
n = 32 |
6 |
Correct |
1 ms |
384 KB |
n = 32 |
7 |
Correct |
1 ms |
384 KB |
n = 32 |
8 |
Correct |
1 ms |
384 KB |
n = 32 |
9 |
Correct |
1 ms |
384 KB |
n = 32 |
10 |
Correct |
1 ms |
384 KB |
n = 32 |
11 |
Correct |
1 ms |
384 KB |
n = 32 |
12 |
Correct |
1 ms |
384 KB |
n = 32 |
13 |
Correct |
1 ms |
384 KB |
n = 32 |
14 |
Correct |
1 ms |
384 KB |
n = 32 |
15 |
Correct |
1 ms |
384 KB |
n = 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
n = 32 |
2 |
Correct |
1 ms |
384 KB |
n = 32 |
3 |
Correct |
1 ms |
384 KB |
n = 32 |
4 |
Correct |
1 ms |
384 KB |
n = 32 |
5 |
Correct |
1 ms |
384 KB |
n = 32 |
6 |
Correct |
1 ms |
384 KB |
n = 32 |
7 |
Correct |
1 ms |
384 KB |
n = 32 |
8 |
Correct |
1 ms |
384 KB |
n = 32 |
9 |
Correct |
1 ms |
384 KB |
n = 32 |
10 |
Correct |
1 ms |
384 KB |
n = 32 |
11 |
Correct |
1 ms |
384 KB |
n = 32 |
12 |
Correct |
1 ms |
384 KB |
n = 32 |
13 |
Correct |
1 ms |
384 KB |
n = 32 |
14 |
Correct |
1 ms |
384 KB |
n = 32 |
15 |
Correct |
1 ms |
384 KB |
n = 32 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
512 KB |
n = 128 |
2 |
Correct |
5 ms |
512 KB |
n = 128 |
3 |
Correct |
4 ms |
512 KB |
n = 128 |
4 |
Correct |
5 ms |
512 KB |
n = 128 |
5 |
Correct |
4 ms |
512 KB |
n = 128 |
6 |
Correct |
4 ms |
512 KB |
n = 128 |
7 |
Correct |
4 ms |
512 KB |
n = 128 |
8 |
Correct |
4 ms |
512 KB |
n = 128 |
9 |
Correct |
5 ms |
512 KB |
n = 128 |
10 |
Correct |
4 ms |
512 KB |
n = 128 |
11 |
Correct |
4 ms |
512 KB |
n = 128 |
12 |
Correct |
4 ms |
512 KB |
n = 128 |
13 |
Correct |
4 ms |
512 KB |
n = 128 |
14 |
Correct |
5 ms |
512 KB |
n = 128 |
15 |
Correct |
5 ms |
580 KB |
n = 128 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
512 KB |
n = 128 |
2 |
Correct |
4 ms |
512 KB |
n = 128 |
3 |
Correct |
4 ms |
512 KB |
n = 128 |
4 |
Correct |
4 ms |
512 KB |
n = 128 |
5 |
Correct |
4 ms |
512 KB |
n = 128 |
6 |
Correct |
4 ms |
512 KB |
n = 128 |
7 |
Correct |
5 ms |
512 KB |
n = 128 |
8 |
Correct |
4 ms |
544 KB |
n = 128 |
9 |
Correct |
4 ms |
512 KB |
n = 128 |
10 |
Correct |
4 ms |
512 KB |
n = 128 |
11 |
Correct |
4 ms |
512 KB |
n = 128 |
12 |
Correct |
5 ms |
512 KB |
n = 128 |
13 |
Correct |
4 ms |
512 KB |
n = 128 |
14 |
Correct |
4 ms |
512 KB |
n = 128 |
15 |
Correct |
4 ms |
512 KB |
n = 128 |