# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1199085 | djs100201 | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include "messy.h"
set<int>candidate[128];
vector<int> restore_permutation(int n, int w, int r)
{
vector<int> res(n), rev(n),pl(3);
//일단 0,1,2는 알아야 함
for(int i=1;i<8;i++){
string S(n, '0'), temp(n, '0');
if(i&1)S[0]='1';
if(i&2)S[1]='1';
if(i&4)S[2]='1';
for(int j=3;j<n;j++){
if(j&(1<<(i-1)))S[j]='1';
}
add_element(S);
}
string S(n, '1');
for (int i = 0; i < 3; i++)
{
S[i] = '0';
add_element(S);
}
compile_set();
for (int ii = 0; ii < 3; ii++)
{
for (int i = 0; i < n; i++)
{
if (temp[i] == '1')
continue;
temp[i] = '1';
if (check_element(temp))
{
res[i] = ii;
pl[ii]=i;
break;
}
temp[i] = '0';
}
}
for(int i=3;i<n;i++){
for(int j=0;j<n;j++){
if(pl[0]==j || pl[1]==j || pl[2]==j)continue;
candidate[i].push_back(j);
//i->j였음.
}
}
for(int i=1;i<8;i++){
string S(n, '0'), temp;
if(i&1)S[0]='1';
if(i&2)S[1]='1';
if(i&4)S[2]='1';
vector<int>checked(now);
for(int j=0;j<n;j++){
if(pl[0]==j || pl[1]==j || pl[2]==j)continue;
temp=S;
temp[j]='1';
if(check_element(temp))checked[j]=1;
}
for(int j=3;j<n;j++){
if(j&(1<<(i-1))){
for (auto it = st[j].begin(); it != st[j].end(); ) {
if (!checked[*it]) {
it = st[j].erase(it); // erase는 삭제 후 다음 iterator 반환
} else {
++it;
}
}
}
}
}
for(int i=3;i<n;i++){
int x=*st[i].begin();
res[x]=i;
}
return res;
}