| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1297142 | thesentro | Unscrambling a Messy Bug (IOI16_messy) | C++20 | 2 ms | 356 KiB |
#include <vector>
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
#define ll int
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
std::vector<int> restore_permutation(int n, int w, int r) {
// add_element("0");
// compile_set();
// check_element("0");
string ret(n, '0');
for (int i=0 ; i<n-1 ; i++)
{
ret[i] = '1';
add_element(ret);
// cout<<ret<<endl;
}
compile_set();
vector<ll>res(n, -1);
string temp(n, '0');
for (int i=0 ; i<n-1 ; i++)
{
vector<ll>b(n, 1);
ll cnt=n-i;
for (int j=0 ; j<n ; j++)
{
if (temp[j]=='1')
b[j] = 0;
}
while (true)
{
ll v = (cnt==1)? 0:rng()%cnt;
v++;
ll sum=0;
ll val;
for (int j=0 ; j<n ; j++)
{
sum += b[j];
if (sum==v)
{
val = j;
break;
}
}
b[val] = 0;
cnt--;
temp[val] = '1';
if (check_element(temp))
{
res[val] = i;
break;
}
else
temp[val] = '0';
}
}
for (int i=0 ; i<n ; i++)
{
if (res[i]==-1)
{
res[i] = n-1;
break;
}
}
return res;
}
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... | ||||
