# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
573933 | 2fat2code | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 3 ms | 340 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"
#define fr first
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sc second
#define all(s) s.begin(), s.end()
#define rc(s) return cout << s, 0
using namespace std;
vector<int> restore_permutation(int n, int w, int r) {
string s = "";
for(int i=1;i<=n;i++) s += '0';
for(int i=0;i<n;i++){
s[i] = '1';
add_element(s);
}
compile_set();
vector<int>p;
vector<int>pos;
string curr = "";
for(int i=1;i<=n;i++) curr += "0";
for(int i=1;i<=n;i++) pos.push_back(i - 1);
for(int t=1;t<n;t++){
curr[pos[0]] = '1';
if(check_element(curr)){
p.push_back(pos[0]);
vector<int>tz;
for(int i=1;i<(int)pos.size();i++) tz.push_back(pos[i]);
pos = tz;
continue;
}
for(int i=1;i<pos.size()-1;i++){
curr[pos[i-1]] = '0';
curr[pos[i]] = '1';
if(check_element(curr)){
p.push_back(pos[i]);
vector<int>tz;
for(int j=0;j<i;j++) tz.push_back(pos[j]);
for(int j=i+1;j<pos.size();j++) tz.push_back(pos[j]);
pos = tz;
break;
}
}
if(pos.size() == n - t + 1){
if(pos.size() >= 2){
curr[pos[pos.size() - 2]] = '0';
}
curr[pos.back()] = '1';
p.push_back(pos.back());
pos.pop_back();
}
}
p.push_back(pos.back());
vector<int>lol(n, 0);
for(int i=0;i<n;i++) lol[p[i]] = i;
return lol;
}
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... |