Submission #395076

#TimeUsernameProblemLanguageResultExecution timeMemory
395076idk321Unscrambling a Messy Bug (IOI16_messy)C++11
0 / 100
2 ms332 KiB
#include <vector>

#include "messy.h"

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

/*
string toBin(int num)
{
    string res;
    while (num > 0)
    {
        res += (num %= 2) - '0';
        res /= 2;
    }

    return res;
}*/

std::vector<int> restore_permutation(int n, int w, int r) {

    for (int i = 1; i < n; i++)
    {
        string cur;
        for (int j = 0; j < i; j++) cur += '1';
        for (int j = i; j < n; j++) cur += '0';
        add_element(cur);
    }

    compile_set();

    vector<int> perm(n);
    string cur (n, '0');
    for (int i = 1; i <= n; i++)
    {
        vector<int> on;
        for (int j = 0; j < n; j++) if (cur[j] == '0') on.push_back(j);
        unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
        shuffle (on.begin(), on.end(), std::default_random_engine(seed));

        for (int j : on)
        {
            cur[j] = '1';
            if (check_element(cur))
            {
                perm[i - 1] = j;
                break;
            }
            cur[j] = '0';
        }
    }

    return perm;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...