# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1245017 | chinesegenius69420 | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
#include "messy.h"
#define dbg(x) cerr << #x << ": " << x << "\n";
using namespace std;
vector<int> restore_permutation(int n, int w, int r) {
for(int i = 1; i < n; i++){
string aux = "";
for(int j = 0; j < i; j++){
aux += '1';
}
for(int j = i + 1; j <= n; j++){
aux += '0';
}
add_element(aux);
}
compile_set();
vector<int> pos;
while(pos.size() != n - 1){
string aux(n, '0');
for(const int &i : pos){
aux[i] = '1';
}
int actpos = 0;
while(actpos < n and aux[actpos] == '1') actpos++;
while(1){
aux[actpos] = '1';
if(check_element(aux)){
break;
}
aux[actpos] = '0';
actpos++;
while(actpos < n and aux[actpos] == '1') actpos++;
}
pos.push_back(actpos);
}
int x = 0, y = n * (n - 1) / 2;
for(const int &i : pos) x += i;
pos.push_back(y - x);
vector<int> ans(n);
for(int i = 0; i < n; i++){
ans[pos[i]] = i;
}
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... |