Submission #426411

#TimeUsernameProblemLanguageResultExecution timeMemory
426411timmyfengUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms512 KiB
#include <bits/stdc++.h>
using namespace std;

#include "messy.h"

vector<int> restore_permutation(int n, int w, int r) {
    string mask(n, '0');
    for (int i = 1; i < n; i *= 2) {
        string new_mask(n, '0');
        for (int j = 0; j < n; ++j) {
            if ((i & j) > 0) {
                new_mask[j] = '1';
                mask[j] ^= '0' ^ '1';
                add_element(mask);
                mask[j] ^= '0' ^ '1';
            }
        }
        mask = new_mask;
    }

    compile_set();

    vector<int> ans(n);
    mask = string(n, '0');
    for (int i = 1; i < n; i *= 2) {
        string new_mask(n, '0');
        for (int j = 0; j < n; ++j) {
            mask[j] ^= '0' ^ '1';
            if (check_element(mask)) {
                new_mask[j] = '1';
                ans[j] += i;
            }
            mask[j] ^= '0' ^ '1';
        }
        mask = new_mask;
    }

    return ans;
}
#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...