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 "messy.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> restore_permutation(int N, int W, int R)
{
// Try with different bitcounts:
// 1000
// 1100
// 1110
// w = n - 1
// r = n*(n+1)/2 - 1
string element(N, '0');
for (int i = 0; i < N - 1; i++)
{
element[i] = '1';
add_element(element);
}
compile_set();
vector<int> perm(N, -1);
string securedBits(N, '0');
for (int i = 0; i < N; i++)
{
for (int j = 0; j < N; j++)
{
if (securedBits[j] == '1') continue;
securedBits[j] = '1';
if (check_element(securedBits))
{
perm[i] = j;
break;
}
securedBits[j] = '0';
}
}
int sum = 0;
for (int i = 0; i < N - 1; i++)
sum += perm[i];
perm.back() = (N * N - N) / 2 - sum;
return perm;
}
# | 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... |