# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1254372 | denislav | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 1 ms | 328 KiB |
# include <iostream>
# include <vector>
# include <algorithm>
# include <random>
using namespace std;
# include "messy.h"
//# include "grader.cpp"
mt19937 rng(1707);
const int MAX=128;
int n;
bool rem[MAX];
std::vector<int> restore_permutation(int N, int w, int r)
{
n=N;
for(int i=0;i<n;i++)
{
string s(n,'0');
for(int j=0;j<i;j++) s[j]='1';
add_element(s);
}
compile_set();
string s(n,'1');
vector<int> p(n);
for(int k=n-1;k>=0;k--)
{
vector<int> remain;
for(int i=0;i<n;i++)
{
if(!rem[i]) remain.push_back(i);
}
shuffle(remain.begin(),remain.end(),rng);
for(int i: remain)
{
if(rem[i]) continue;
s[i]='0';
if(check_element(s))
{
p[i]=k;
rem[i]=1;
break;
}
else s[i]='1';
}
}
return p;
}
/*
4 128 128
0 1 2 3
*/
/*
8 128 128
0 1 2 4 3 5 6 7
*/
/*
8 128 128
3 2 1 4 5 7 6 0
*/
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... |