# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
291146 | peti1234 | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
string s;
const int c=128;
vector<int> bal;
int n, po;
vector<int> restore_permutation(int x) {
n=x, po=x;
for (int i=0; i<n; i++) s+='0', bal.push_back(0);
while(po>1) {
for (int i=0; i<n; i+=po) {
int mid=i+po/2;
for (int j=0; j<n; j++) {
s[i]='0';
if (j>=i && j<i+po) s[i]='1';
}
for (int j=i; j<mid; j++) {
s[j]='0';
add_element(s);
s[j]='1';
}
}
po/=2;
}
compile_set(), po=x;
while(po>1) {
for (int i=0; i<n; i+=po) {
int mid=i+po/2;
for (int j=0; j<n; j++) {
s[i]='0';
if (bal[j]==i) s[i]='1';
}
for (int j=0; j<n; j++) {
if (bal[j]==i) {
s[i]='0';
bool f=check_element(s);
s[i]='1';
if (!f) bal[j]+=po/2;
}
}
}
po/=2;
}
return bal;
}