이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
#include "messy.h"
using namespace std;
#define all(x) begin(x),end(x)
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#define debug(a) cerr << "(" << #a << ": " << a << ")\n";
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int mxN = 1e5+1, oo = 1e9;
int N;
void queries(int l, int r) {
if(l==r) return;
int mid = (l+r)/2;
for(int i=l;i<=mid;++i) {
string q(N,'0');
for(int j=l;j<=r;++j) {
if(j!=i) q[j]++;
}
add_element(q);
}
queries(l,mid);
queries(mid+1,r);
}
void get(int l, int r, vi got, vi& ans) {
if(l==r) {
ans[got[0]]=l;
return;
}
vi left,right;
for(int i: got) {
string q(N,'0');
for(int j: got) {
if(i!=j) {
q[j]++;
}
}
if(check_element(q)) {
left.push_back(i);
} else right.push_back(i);
}
int mid = (l+r)/2;
get(l,mid, left,ans);
get(mid+1,r, right,ans);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N=n;
queries(0,n-1);
compile_set();
vi got(n);
iota(all(got),0);
vi ans(n,-1);
get(0,n-1,got,ans);
return ans;
}
# | 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... |