# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
576249 | AugustinasJucas | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 3 ms | 504 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>
#include "messy.h"
using namespace std;
int n;
string nl;
vector<int> ans;
vector<int> nera(vector<int> a ) {
vector<int> ret;
set<int> setas;
for(auto &x : a) setas.insert(x);
for(int i = 0; i < n; i++) {
if(setas.count(i) == 0) ret.push_back(i);
}
return ret;
}
string nr(vector<int> x ) {
string ret = nl;
for(auto &y : x) ret[y] = '1';
return ret;
}
void darom(vector<int> mas) {
if(mas.size() == 1) return ;
vector<int> a, b;
for(int i = 0; i < mas.size()/2; i++) {
a.push_back(mas[i]);
b.push_back(mas[i+mas.size()/2]);
}
string s = nr(nera(mas));
for(auto &x : b) {
s[x] = '1';
add_element(s);
s[x] = '0';
}
darom(a);
darom(b);
}
int sk = 0;
void rask(vector<int> mas) {
if(mas.size() == 1) {
ans[mas[0]] = sk;
return ;
}
string s = nr(nera(mas));
vector<int> a, b;
for(auto &x : mas){
s[x] = '1';
if(check_element(s) == 1) {
a.push_back(x);
}else {
b.push_back(x);
}
s[x] = '0';
}
sk = sk * 2 + 1;
rask(a);
sk--;
rask(b);
sk /= 2;
}
vector<int> restore_permutation(int N, int w, int r) {
/* add_element("0");
compile_set();
check_element("0");
*/
n = N;
ans.resize(n);
for(int i = 0; i < n; i++) nl.push_back('0');
vector<int> ms;
for(int i = 0; i < n; i++) ms.push_back(i);
darom(ms);
compile_set();
rask(ms);
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... |