Submission #293827

#TimeUsernameProblemLanguageResultExecution timeMemory
293827Aldas25Unscrambling a Messy Bug (IOI16_messy)C++14
49 / 100
1 ms384 KiB
#include <vector>

#include <bits/stdc++.h>

#include "messy.h"

using namespace std;

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define f first
#define s second
#define pb push_back
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

    vi shuf(n);
    FOR(x, 0, n-1) shuf[x] = x;
    shuffle(shuf.begin(), shuf.end(), rng);
    string s = "";
    REP(n) s += "0";
    FOR(x, 0, n-1) {
        int i = shuf[x];
        s[i] = '1';
        add_element(s);
    }

    compile_set();

    vi perm(n);

    string cur = "";
    REP(n) cur += "0";
    FOR(y, 0, n-1) {
        int i = shuf[y];
        //shuffle(shuf.begin(), shuf.end(), rng);
        FOR(x, 0, n-1) {
            int j = shuf[x];
            if (cur[j] == '1') continue;
            cur[j] = '1';
            bool ok = check_element(cur);
            if (ok) {
                perm[j] = i;
                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...