# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170384 | arnold518 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 4 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N, W, R;
vector<int> ans;
void put(int s, int e)
{
if(s+1==e) return;
int i, j;
int mid=s+e>>1;
string S(N, '0');
for(i=0; i<N; i++) if(!(s<=i && i<e)) S[i]='1';
for(i=s; i<mid; i++)
{
S[i]='1';
add_element(S);
S[i]='0';
}
put(s, mid);
put(mid, e);
}
void get(int s, int e, vector<int> cand)
{
if(s+1==e)
{
ans[s]=cand[0];
return;
}
int i, j;
int mid=s+e>>1;
string S(N, '0');
for(i=0; i<N; i++) if(!binary_search(cand.begin(), cand.end(), i)) S[i]='1';
vector<int> L, R;
for(auto it : cand)
{
S[it]='1';
if(check_element(S)) L.push_back(it);
else R.push_back(it);
S[it]='0';
}
get(s, mid, L);
get(mid, e, R);
}
vector<int> restore_permutation(int _N, int _W, int _R)
{
int i, j;
N=_N; W=_W; R=_R;
ans.resize(N);
vector<int> V;
for(i=0; i<N; i++) V.push_back(i);
put(0, N);
compile_set();
get(0, N, V);
return ans;
}
Compilation message (stderr)
# | 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... |