이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair<int,int> pii;
typedef vector<long long> vl;
typedef vector<int> vi;
int n;
string create1(int l, int r, int x){
string ret;
for(int i = 0; i < n; i++){
if(i != x && l <= i && i <= r) ret+="0";
else ret+="1";
}
return ret;
}
string create2(vi cand, int x){
string ret;
for(int i = 0; i < n; i++){
if(i != x && find(cand.begin(), cand.end(), i) != cand.end()) ret += "0";
else ret += "1";
}
return ret;
}
void solve1(int l, int r){
if(l == r) return;
int mid = (l + r) / 2;
for(int i = l; i <= mid; i++){
add_element(create1(l, r, i));
}
solve1(l, mid);
solve1(mid+1, r);
}
vi res;
void solve2(int l, int r, vi cand){
if(l == r){
res[cand[0]] = l;
return;
}
int mid = (l + r) / 2;
vi left, right;
for(auto x : cand){
if(check_element(create2(cand, x))) left.pb(x);
else right.pb(x);
}
solve2(l, mid, left);
solve2(mid+1, r, right);
}
vi restore_permutation(int _n, int w, int r){
n = _n;
solve1(0, n-1);
compile_set();
vi cand(n);
for(int i = 0; i < n; i++)
cand[i] = i;
res.resize(n);
solve2(0, n-1, cand);
return res;
}
# | 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... |