이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
#define DIM 300
using namespace std;
string a[DIM];
int k,n,w,r,pas;
int p[DIM],v[DIM];
vector <int> sol;
/*void add_element(string s){
a[++k] = s;
}
void compile_set(){
for (int i=1;i<=k;i++){
string s = "";
for (int j=0;j<n;j++)
s += a[i][p[j]];
a[i] = s;
}
}
int check_element(string s){
pas++;
for (int i=1;i<=k;i++)
if (a[i] == s)
return 1;
return 0;
}*/
void add (int st, int dr){
if (st == dr)
return;
int mid = (st+dr)>>1;
string s = "";
for (int i=0;i<n;i++){
if (i < st || i > dr)
s += "1";
else s += "0";
}
for (int i=st;i<=mid;i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
add (st,mid);
add (mid+1,dr);
}
void solve (string s, int st, int dr){
if (st == dr){
for (int i=0;i<n;i++){
if (s[i] == '0'){
sol[i] = st;
break;
}}
return;
}
int mid = (st+dr)>>1;
vector <int> poz,poz2;
for (int i=0;i<=n-1;i++){
if (s[i] == '1')
continue;
s[i] = '1';
if (check_element(s) == 0)
poz.push_back(i);
else poz2.push_back(i);
s[i] = '0';
}
for (auto it : poz)
s[it] = '1';
solve (s,st,mid);
for (auto it : poz)
s[it] = '0';
for (auto it : poz2)
s[it] = '1';
solve (s,mid+1,dr);
}
vector<int> restore_permutation (int N, int w, int r){
int i;
n = N;
add (0,n-1);
compile_set();
string s = "";
for (i=0;i<n;i++){
sol.push_back(0);
s += "0";
}
solve (s,0,n-1);
return sol;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |