이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <cstdlib>
#include <iostream>
#include "messy.h"
#include <numeric>
#include <algorithm>
#include <random>
#include <chrono>
using namespace std;
vector<int> restore_permutation(int N, int W, int R){
string s = string(N, '0'), t = string(N, '0');
for(int i = 0; i < N/2; i ++){
s[i] = '1';
//cout << s << endl;
add_element(s);
s[i] = '0';
s[N-i-1] = '1';
//cout << s << endl;
add_element(s);
s[i] = '1';
}
string ss = string(N, '1');
ss[0] = '0';
add_element(ss);
t[0] = '1';
for(int i = 0; i < N/2-1; i ++){
t[i + 1] = '1';
//cout << t << endl;
add_element(t);
t[i] = '0';
}
vector<int> order(N);
iota(order.begin(), order.end(), 0);
compile_set();
string ans = string(N, '0');
vector<vector<int>> pos(N/2);
vector<int> perm(N, -1);
for(int i = 0; i < N/2; i ++){
string temp = ans;
for(int j = 0; j < N; j ++){
if(ans[j] == '0'){
temp[j] = '1';
bool good = check_element(temp);
if(good){
ans[j] = '1';
pos[i].push_back(j);
}
temp[j] = '0';
}
}
}
perm[pos[0][0]] = 0;
perm[pos[0][1]] = N-1;
ss[0] = '1';
ss[pos[0][0]] = '0';
if(!check_element(ss)){
swap(perm[pos[0][0]], perm[pos[0][1]]);
}
for(int i = 1; i < N/2; i ++){
string temp = string(N, '0');
temp[find(perm.begin(), perm.end(), i-1)-perm.begin()] = '1';
temp[pos[i][0]] = '1';
//cout << temp << endl;
if(check_element(temp)){
//cout << "WTF" << endl;
perm[pos[i][0]] = i;
perm[pos[i][1]] = N-i-1;
}
else{
//cout << "LOL" << endl;
perm[pos[i][1]] = i;
perm[pos[i][0]] = N-i-1;
}
}
return perm;
}
# | 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... |