제출 #1121598

#제출 시각아이디문제언어결과실행 시간메모리
1121598Captain_GeorgiaUnscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
2 ms592 KiB
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;

mt19937 rng(time(NULL));

std::vector<int> restore_permutation(int N, int w, int r) {
    string S(N, '0'), res(N, '0');
    for (int i = 0;i < N;i ++) {
        S[i] = '1';
        add_element (S);
    }
    compile_set ();
    vector<int> p(N, 0), used(N, 0);

    vector<int> index(N);
    for (int i = 0;i < N;i ++) index.push_back(i);
    shuffle(index.begin(), index.end(), rng);

    function<void(int)> func = [&](int ind) -> void {
        if (ind == N) return;
        for (auto i : index) if (used[i] == 0) {
            res[i] = '1';
            if (check_element (res) == 1) {
                used[i] =  1;
                p[i] = ind;
                break;
            }
            res[i] = '0';
        }
        func (ind + 1);
    };
    func (0);
    return p;
}
#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...