Submission #47304

#TimeUsernameProblemLanguageResultExecution timeMemory
47304TAMREFUnscrambling a Messy Bug (IOI16_messy)C++11
20 / 100
3 ms640 KiB
#include <bits/stdc++.h>
#include "messy.h"

using namespace std;

int b;
vector<int> pp;
bool mark[128];

vector<int> restore_permutation(int n, int w, int r) {
    string S;
    pp.resize(n);
    for(int i = 0; i < n; i++) pp[i] = -1;

    for(int i = 0; i < n; i++) S += '0';
    for(int exc = 0; exc < n - 1; exc++){
        for(int i = exc + 1; i < n; i++){
            S[i] = '1';
            add_element(S);
            S[i] = '0';
        }
        S[exc] = '1';
    }
    compile_set();
    S.clear();
    for(int i = 0; i < n; i++) S += '0';
    for(int exc = 0; exc < n - 1; exc++){
        for(int i = 0; i < n; i++){
            if(S[i] == '1') continue;
            S[i] = '1';
            if(!check_element(S)){
                pp[exc] = i;
                mark[i] = 1;
            }
            S[i] = '0';
        }
        if(pp[exc] == -1){
            pp[exc] = exc;
            mark[exc] = 1;
        }
        S[pp[exc]] = '1';
    }
    for(int i = 0; i < n; i++){
        if(!mark[i]){
            pp[n-1] = i;
            break;
        }
    }
    vector<int> qq(n);
    for(int i = 0; i < n; i++) qq[pp[i]] = i;
    return qq;
}
#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...