#include "messy_c.h"
#define N 128
void solve_add(int n, int w, int r, int x, int y)
{
if (x == y) return;
char ask[N+1]={0};
for(int i=0;i<n;++i)ask[i]='0' + (i<x||i>y);
int m = x+(y-x)/2;
for(int i=x;i<=m;++i)
{
ask[i]='1';
add_element(ask);
ask[i]='0';
}
solve_add(n, w, r, x, m);
solve_add(n, w, r, m+1, y);
}
void solve_restore(int n, int w, int r, int x, int y, int *mapped, int *result)
{
if (x == y) { result[x] = mapped[0]; return; }
char ask[N+1]={0};
for(int i=0;i<n;++i)ask[i]='1';
for(int i=x;i<=y;++i)ask[mapped[i-x]]='0';
int nmapped[N],no=0,mmapped[N],mo=0;
int m=x+(y-x)/2;
for(int i=x;i<=m;++i)
{
ask[mapped[i-x]]='1';
if(check_element(ask))
nmapped[no++]=mapped[i-x];
else
mmapped[mo++]=mapped[i-x];
ask[mapped[i-x]]='0';
}
solve_restore(n, w, r, x, m, nmapped, result);
solve_restore(n, w, r, m+1, y, mmapped, result);
}
void restore_permutation(int n, int w, int r, int* result)
{
solve_add(n, w, r, 0, n-1);
compile_set();
int mapped[N];
for (int i = 0; i < n; ++i) mapped[i] = i;
solve_restore(n, w, r, 0, n-1, mapped, result);
}
# |
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 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
604 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4440 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
4444 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |