이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//by szh
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
#include "messy.h"
vector <int> ans;
int N;
void solve(vector<int> pos) {
if (SZ(pos)==1) return;
int mid = SZ(pos)>>1;
string s;
rep(i,0,N) s+="1";
for (int v:pos) s[v] = '0';
vector <int> pl,pr;
rep(i,0,mid) {
int v = pos[i];
s[v] = '1';
add_element(s);
s[v] = '0';
pl.pb(v);
}
rep(i,mid,SZ(pos)) pr.pb(pos[i]);
solve(pl);
solve(pr);
}
void query(vector <int> pos,vector <int> val) {
if (SZ(pos)==1) {
ans[val[0]] = pos[0];
return;
}
string q;
rep(i,0,N) q+="1";
for (int v:val) q[v] = '0';
vector <int> vl,vr;
for (int v:val) {
q[v] = '1';
if (check_element(q)) vl.pb(v);
else vr.pb(v);
q[v] = '0';
}
vector <int> pl,pr;
rep(i,0,SZ(pos)/2) pl.pb(pos[i]),pr.pb(pos[i+SZ(pos)/2]);
query(pl,vl),query(pr,vr);
}
std::vector<int> restore_permutation(int n, int w, int r) {
N=n;
ans.resize(n);
vector <int> p,v;
rep(i,0,n) p.pb(i),v.pb(i);
solve(p);
compile_set();
query(p,v);
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... |