#include<iostream>
#include<vector>
#include<string>
#include "messy.h"
using namespace std;
static int n, v[130];
static vector<int> sol;
void calc(int st, int dr){
if(st != dr){
int mid = (st + dr) / 2, i;
string s;
for(i = 0; i < n; i++){
if(i < st || i > dr){
s += '1';
}
else{
s += '0';
}
}
for(i = st; i <= mid; i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
calc(st, mid);
calc(mid + 1, dr);
}
}
void solve(int st, int dr, int v[]){
if(st == dr){
sol[ v[0] ] = st;
return;
}
int i, mid = (st + dr) / 2, u;
string s;
int vst[130], vdr[130];
for(i = 0; i < n; i++){
if(i < st || i > dr){
s += '1';
}
else{
s += '0';
}
}
for(i = 0; i < dr - st + 1; i++){
s[ v[i] ] = '0';
}
u = 0;
for(i = st; i <= dr; i++){
while(u < dr - st + 1 && v[u] < i){
u++;
}
if(v[u] != i){
s[i] = '1';
}
}
u = 0;
for(i = 0; i < dr - st + 1; i++){
s[ v[i] ] = '1';
if( check_element(s) ){
vst[u++] = v[i];
}
else{
vdr[i - u] = v[i];
}
s[ v[i] ] = '0';
}
solve(st, mid, vst);
solve(mid + 1, dr, vdr);
}
vector<int> restore_permutation(int N, int w, int r){
n = N;
calc(0, n - 1);
compile_set();
sol.resize(n);
for(int i = 0; i < n; i++){
v[i] = i;
}
solve(0, n - 1, v);
return sol;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
n = 8 |
2 |
Correct |
2 ms |
376 KB |
n = 8 |
3 |
Correct |
2 ms |
256 KB |
n = 8 |
4 |
Correct |
2 ms |
376 KB |
n = 8 |
5 |
Correct |
2 ms |
256 KB |
n = 8 |
6 |
Correct |
2 ms |
380 KB |
n = 8 |
7 |
Correct |
2 ms |
376 KB |
n = 8 |
8 |
Correct |
2 ms |
256 KB |
n = 8 |
9 |
Correct |
2 ms |
252 KB |
n = 8 |
10 |
Correct |
2 ms |
256 KB |
n = 8 |
11 |
Correct |
2 ms |
256 KB |
n = 8 |
12 |
Correct |
2 ms |
256 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 |
3 ms |
504 KB |
n = 32 |
2 |
Correct |
2 ms |
376 KB |
n = 32 |
3 |
Correct |
2 ms |
376 KB |
n = 32 |
4 |
Correct |
2 ms |
376 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 |
376 KB |
n = 32 |
10 |
Correct |
2 ms |
356 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 |
2 ms |
348 KB |
n = 32 |
2 |
Correct |
2 ms |
376 KB |
n = 32 |
3 |
Correct |
2 ms |
372 KB |
n = 32 |
4 |
Correct |
2 ms |
376 KB |
n = 32 |
5 |
Correct |
5 ms |
380 KB |
n = 32 |
6 |
Correct |
2 ms |
376 KB |
n = 32 |
7 |
Correct |
2 ms |
380 KB |
n = 32 |
8 |
Correct |
2 ms |
376 KB |
n = 32 |
9 |
Correct |
2 ms |
380 KB |
n = 32 |
10 |
Correct |
2 ms |
364 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 |
1 ms |
376 KB |
n = 32 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
504 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 |
508 KB |
n = 128 |
8 |
Correct |
4 ms |
508 KB |
n = 128 |
9 |
Correct |
4 ms |
508 KB |
n = 128 |
10 |
Correct |
4 ms |
508 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 |
504 KB |
n = 128 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
504 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 |
552 KB |
n = 128 |
9 |
Correct |
4 ms |
504 KB |
n = 128 |
10 |
Correct |
4 ms |
632 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 |
504 KB |
n = 128 |