이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
#include "messy.h"
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);
vi tr[512];
void add(int n, int l, int r) {
if (l == r) return;
string s = "";
F0R(i, n) {
if (i < l || i > r) s += "1";
else s += "0";
}
FOR(i, l, (l + r)/2 + 1) {
s[i] = '1';
add_element(s);
s[i] = '0';
}
add(n, l, (l + r)/2);
add(n, (l + r) / 2 + 1, r);
}
void query(int n, int pos) {
string s = "";
F0R(i, n) s += "0";
int j = pos;
while (j) {
for (int i : tr[j ^ 1]) s[i] = '1';
j /= 2;
}
F0R(i, n) {
if (s[i] == '1') continue;
s[i] = '1';
if (check_element(s)) tr[pos * 2].pb(i);
else tr[pos * 2 + 1].pb(i);
s[i] = '0';
}
}
vi restore_permutation(int n, int w, int r) {
//string s = "";
add(n, 0, n - 1);
compile_set();
FOR(i, 1, n) query(n, i);
vi res;
F0R(i, n) {
res.pb(0);
}
FOR(i, n, 2 * n) {
res[tr[i][0]] = i - n;
}
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... |