Submission #594967

#TimeUsernameProblemLanguageResultExecution timeMemory
594967Valaki2Unscrambling a Messy Bug (IOI16_messy)C++14
49 / 100
1 ms340 KiB
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;

#define n N

#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

int n;
vector<int> p;

void solve() {
    string add(n, '0');
    for(int i = 0; i < n; i++) {
        add[i] = '1';
        add_element(add);
    }
    compile_set();
    string check(n, '0');
    for(int k = 0; k < n; k++) {
        vector<int> ind;
        for(int i = 0; i < n; i++) {
            if(p[i] == -1) {
                ind.pb(i);
            }
        }
        random_shuffle(ind.begin(), ind.end());
        for(int i : ind) {
            check[i] = '1';
            if(i == ind.back() || check_element(check)) {
                p[i] = k;
                break;
            }
            check[i] = '0';
        }
        /*for(int i = 0; i < n; i++) {
            if(p[i] != -1) {
                continue;
            }
            check[i] = '1';
            if(check_element(check)) {
                p[i] = k;
                break;
            }
            check[i] = '0';
        }*/
    }
}

#undef n
vector<int> restore_permutation(int n, int w, int r) {
    srand(1234);
    N = n;
    p.assign(N, -1);
    solve();
    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...