Submission #742792

#TimeUsernameProblemLanguageResultExecution timeMemory
742792ALTAKEXEUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms496 KiB
#include "messy.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
 
vector<int> restore_permutation(int n, int w, int r){
    int k = __builtin_ctz(n);
 
    for(int i = 0; i < n; i++) for(int j = 0; j < k; j++){
        if(!(i&(1<<j))) continue;
        if(j == 0){
            str s(n, '0');
            s[i] = '1';
            add_element(s);
            continue;
        }
        str s(n, '0');
        for(int l = 0; l < n; l++){
            if(l%(1<<j) + i%(1<<j) == (1<<j)-1) s[l] = '1';
        }
        s[i] = '1';
        add_element(s);
    }
 
    compile_set();
 
    vector<int> p(n, 0);
    vector<str> sth(n);
 
    for(int j = 0; j < k; j++){
        if(j == 0){
            for(int i = 0; i < n; i++){
                str s(n, '0');
                s[i] = '1';
                if(check_element(s)) p[i]+=(1<<j);
            }
            continue;
        }
 
        for(int h = 0; h < (1<<j); h++){
            sth[h] = str(n, '0');
            for(int i = 0; i < n; i++)
                if(p[i]%(1<<j) + h == (1<<j)-1) sth[h][i] = '1';
        }
 
        for(int i = 0; i < n; i++){
            str s = sth[p[i]%(1<<j)];
            s[i] = '1';
            if(check_element(s)) p[i]+=(1<<j);
        }
    }
 
    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...