#include <vector>
#include <iostream>
#include "messy.h"
#include <set>
using namespace std;
void add(int l, int r, string s)
{
if (l + 1 == r) return;
for (int i = l; i < (l + r)/2; i++)
{
string t = s;
t[i] = '1';
add_element(t);
}
string s1 = s;
for (int i = l; i < (l + r)/2; i++)
{
s1[i] = '1';
}
add((l + r)/2, r, s1);
s1 = s;
for (int i = (l + r)/2; i < r; i++)
{
s1[i] = '1';
}
add(l, (l + r)/2, s1);
}
void check(int l, int r, set<int> nr, vector<int> &res, string st)
{
if (nr.size() == 1)
{
for (int i : nr) res[i] = l;
return;
}
set<int> in;
set<int> out;
for (int i : nr)
{
string ot = st;
ot[i] = '1';
if (check_element(ot))
{
in.insert(i);
}
else
{
out.insert(i);
}
}
string s1 = st;
for (int i : out)
{
s1[i] = '1';
}
check(l, (l + r)/2, in, res, s1);
s1 = st;
for (int i : in)
{
s1[i] = '1';
}
check((l + r)/2, r, out, res, s1);
}
vector<int> restore_permutation(int n, int w, int r) {
add(0, n, string(n, '0'));
compile_set();
set<int> rs;
for (int i = 0; i < n; i++)
{
rs.insert(i);
}
vector<int> res(n, -1);
check(0, n, rs, res, string(n, '0'));
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 8 |
2 |
Correct |
2 ms |
376 KB |
n = 8 |
3 |
Correct |
2 ms |
376 KB |
n = 8 |
4 |
Correct |
2 ms |
376 KB |
n = 8 |
5 |
Correct |
2 ms |
376 KB |
n = 8 |
6 |
Correct |
2 ms |
376 KB |
n = 8 |
7 |
Correct |
2 ms |
376 KB |
n = 8 |
8 |
Correct |
2 ms |
376 KB |
n = 8 |
9 |
Correct |
2 ms |
256 KB |
n = 8 |
10 |
Correct |
2 ms |
376 KB |
n = 8 |
11 |
Correct |
2 ms |
376 KB |
n = 8 |
12 |
Correct |
2 ms |
376 KB |
n = 8 |
13 |
Correct |
2 ms |
376 KB |
n = 8 |
14 |
Correct |
2 ms |
376 KB |
n = 8 |
15 |
Correct |
2 ms |
376 KB |
n = 8 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 32 |
2 |
Correct |
2 ms |
376 KB |
n = 32 |
3 |
Correct |
2 ms |
376 KB |
n = 32 |
4 |
Correct |
2 ms |
400 KB |
n = 32 |
5 |
Correct |
2 ms |
376 KB |
n = 32 |
6 |
Correct |
2 ms |
376 KB |
n = 32 |
7 |
Correct |
2 ms |
376 KB |
n = 32 |
8 |
Correct |
2 ms |
376 KB |
n = 32 |
9 |
Correct |
2 ms |
504 KB |
n = 32 |
10 |
Correct |
3 ms |
376 KB |
n = 32 |
11 |
Correct |
3 ms |
376 KB |
n = 32 |
12 |
Correct |
2 ms |
376 KB |
n = 32 |
13 |
Correct |
2 ms |
376 KB |
n = 32 |
14 |
Correct |
2 ms |
376 KB |
n = 32 |
15 |
Correct |
2 ms |
376 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 32 |
2 |
Correct |
2 ms |
380 KB |
n = 32 |
3 |
Correct |
2 ms |
376 KB |
n = 32 |
4 |
Correct |
2 ms |
376 KB |
n = 32 |
5 |
Correct |
2 ms |
296 KB |
n = 32 |
6 |
Correct |
2 ms |
380 KB |
n = 32 |
7 |
Correct |
3 ms |
376 KB |
n = 32 |
8 |
Correct |
2 ms |
376 KB |
n = 32 |
9 |
Correct |
2 ms |
376 KB |
n = 32 |
10 |
Correct |
2 ms |
376 KB |
n = 32 |
11 |
Correct |
2 ms |
376 KB |
n = 32 |
12 |
Correct |
2 ms |
376 KB |
n = 32 |
13 |
Correct |
2 ms |
376 KB |
n = 32 |
14 |
Correct |
2 ms |
376 KB |
n = 32 |
15 |
Correct |
2 ms |
376 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
484 KB |
n = 128 |
2 |
Correct |
4 ms |
504 KB |
n = 128 |
3 |
Correct |
4 ms |
504 KB |
n = 128 |
4 |
Correct |
4 ms |
504 KB |
n = 128 |
5 |
Correct |
4 ms |
504 KB |
n = 128 |
6 |
Correct |
4 ms |
504 KB |
n = 128 |
7 |
Correct |
4 ms |
504 KB |
n = 128 |
8 |
Correct |
4 ms |
504 KB |
n = 128 |
9 |
Correct |
4 ms |
504 KB |
n = 128 |
10 |
Correct |
4 ms |
504 KB |
n = 128 |
11 |
Correct |
4 ms |
504 KB |
n = 128 |
12 |
Correct |
4 ms |
488 KB |
n = 128 |
13 |
Correct |
4 ms |
504 KB |
n = 128 |
14 |
Correct |
4 ms |
504 KB |
n = 128 |
15 |
Correct |
4 ms |
504 KB |
n = 128 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
632 KB |
n = 128 |
2 |
Correct |
4 ms |
504 KB |
n = 128 |
3 |
Correct |
4 ms |
504 KB |
n = 128 |
4 |
Correct |
4 ms |
504 KB |
n = 128 |
5 |
Correct |
4 ms |
504 KB |
n = 128 |
6 |
Correct |
4 ms |
504 KB |
n = 128 |
7 |
Correct |
4 ms |
504 KB |
n = 128 |
8 |
Correct |
4 ms |
504 KB |
n = 128 |
9 |
Correct |
4 ms |
504 KB |
n = 128 |
10 |
Correct |
4 ms |
504 KB |
n = 128 |
11 |
Correct |
4 ms |
504 KB |
n = 128 |
12 |
Correct |
4 ms |
504 KB |
n = 128 |
13 |
Correct |
4 ms |
504 KB |
n = 128 |
14 |
Correct |
4 ms |
504 KB |
n = 128 |
15 |
Correct |
4 ms |
508 KB |
n = 128 |