#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include "messy.h"
using namespace std;
int n;
vector<int>pe;
void recadd(int l,int r)
{
if(l==r)return;
string s;
s.resize(n);
for(int i=0;i<n;i++)s[i]='1';
for(int i=l;i<=r;i++)s[i]='0';
int mid=(l+r)/2;
for(int i=l;i<=mid;i++)
{
s[i]='1';
add_element(s);
s[i]='0';
}
recadd(l,mid);
recadd(mid+1,r);
}
void recask(int l,int r,set<int>se)
{
if(l==r)
{
int pos=(*(se.begin()));
pe[pos]=l;
return;
}
string s;
set<int>other1,other2;
s.resize(n);
for(int i=0;i<n;i++)s[i]='1';
for(int i:se)s[i]='0';
for(int i:se)
{
s[i]='1';
if(check_element(s))other1.insert(i);
s[i]='0';
}
for(int i:se)
{
if(other1.count(i))continue;
other2.insert(i);
}
int mid=(l+r)/2;
recask(l,mid,other1);
recask(mid+1,r,other2);
}
vector<int> restore_permutation(int N, int W, int R)
{
n=N;
pe.resize(n);
recadd(0,n);
compile_set();
set<int>ss;
for(int i=0;i<n;i++)ss.insert(i);
recask(0,n,ss);
return pe;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
604 KB |
grader returned WA |
2 |
Halted |
0 ms |
0 KB |
- |