#include<bits/stdc++.h>
#include "messy.h"
#define pb push_back
using namespace std;
int n;
vector<int>ans;
void build(int l, int r)
{
if(r-l<=1) return;
string s;
for(int i=0; i<n; i++) s+='0';
for(int i=l; i<=r; i++) s[i]='1';
int mid=(l+r)>>1;
for(int i=l; i<=mid; i++)
{
s[i]='0';
add_element(s);
// cout<<"add_element "<<s<<endl;
s[i]='1';
}
build(l, mid);
build(mid+1, r);
}
void calc(vector<int>can, int cur)
{
if(can.size()==1)
{
ans[can[0]]=cur;
return;
}
vector<int>v1, v2;
string s;
for(int i=0; i<n; i++) s+='0';
for(int u : can) s[u]='1';
for(int u : can)
{
s[u]='0';
if(check_element(s)) v1.pb(u);
else v2.pb(u);
s[u]='1';
}
calc(v1, cur);
calc(v2, cur+v1.size());
}
vector<int> restore_permutation(int N, int w, int r)
{
n=N; ans.resize(n);
build(0, n-1);
compile_set();
vector<int>can;
for(int i=0; i<n; i++)
can.pb(i);
calc(can, 0);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
242 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
342 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
331 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
489 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
518 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |