제출 #293825

#제출 시각아이디문제언어결과실행 시간메모리
293825Aldas25Unscrambling a Messy Bug (IOI16_messy)C++14
38 / 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) {
    string s = "";
    REP(n) s += "0";
    FOR(i, 0, n-1) {
        s[i] = '1';
        add_element(s);
    }

    compile_set();

    vi perm(n);

    string cur = "";
    REP(n) cur += "0";
    FOR(i, 0, n-1) {
        vi shuf(n);
        FOR(x, 0, n-1) shuf[x] = x;
        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...