# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
65319 | zubec | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 4 ms | 512 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 <bits/stdc++.h>
using namespace std;
#include "messy.h"
vector <int> ansvec;
int n, cnt;
void solve(int l, int r){
string s;
if (l == r)
return;
for (int i = 0; i < n; i++){
s += '1';
}
for (int i = l-1; i < r; i++){
s[i] = '0';
}
int mid = (l+r)>>1;
for (int i = l-1; i < mid; i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
solve(l, mid);
solve(mid+1, r);
}
void solve2(vector <int> vec){
string s;
if (vec.size() == 1){
ansvec[vec[0]] = cnt++;
return;
}
for (int i = 0; i < n; i++){
s += '1';
}
for (int i = 0; i < vec.size(); i++){
s[vec[i]] = '0';
}
vector <int> vec1, vec2;
for (int i = 0; i < vec.size(); i++){
s[vec[i]] = '1';
if (check_element(s)){
vec1.push_back(vec[i]);
} else
vec2.push_back(vec[i]);
s[vec[i]] = '0';
}
solve2(vec1);
solve2(vec2);
}
std::vector<int> restore_permutation(int n, int w, int r) {
vector <int> poses;
::n = n;
ansvec.resize(n);
for (int i = 0; i < n; i++)
poses.push_back(i);
solve(1, n);
compile_set();
solve2(poses);
return ansvec;
}
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... |