# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
810603 | Andrey | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 1 ms | 468 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 <vector>
#include<bits/stdc++.h>
#include "messy.h"
using namespace std;
string s = "";
vector<int> ans(0);
void yay(int l, int r) {
if(l == r) {
return;
}
int m = (l+r)/2;
yay(l,m);
yay(m+1,r);
for(int i = l; i <= m; i++) {
for(int j = 0; j < s.size(); j++) {
if(j >= l && j <= r) {
s[j] = '1';
}
else {
s[j] = '0';
}
}
s[i] = '0';
add_element(s);
}
}
void dude(int l, int r, vector<int> haha) {
if(l == r) {
ans[haha[0]] = l;
return;
}
vector<int> a(0);
vector<int> b(0);
int m = (l+r)/2;
for(int i = 0; i < s.size(); i++) {
s[i] = '0';
}
for(int i = 0; i < haha.size(); i++) {
s[haha[i]] = '1';
}
for(int i = 0; i < haha.size(); i++) {
s[haha[i]] = '0';
if(check_element(s)) {
a.push_back(haha[i]);
}
else {
b.push_back(haha[i]);
}
s[haha[i]] = '1';
}
dude(l,m,a);
dude(m+1,r,b);
}
vector<int> restore_permutation(int n, int w, int r) {
for(int i = 0; i < n; i++) {
s+='1';
ans.push_back(0);
}
yay(0,n-1);
compile_set();
vector<int> wut(0);
for(int i = 0; i < n; i++) {
wut.push_back(i);
}
dude(0,n-1,wut);
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... |