Submission #345150

# Submission time Handle Problem Language Result Execution time Memory
345150 2021-01-07T05:25:14 Z koketsu "The Lyuboyn" code (IZhO19_lyuboyn) C++14
34 / 100
99 ms 43936 KB
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;

int N, K, T, Cnt;

vector <int> tran, Ans;

bool Used[Mxn];

int bom(string S){
    int Ans = 0;
    for(int i = S.size() - 1; i >= 0; i--){
        Ans += ((S[i] - '0') << i);
    }
    return Ans;
}

string rev(int V){
    string Ans = "";
    while(V > 0){
        Ans += ((V % 2) + '0');
        V /= 2;
    }
    int P = Ans.size();
    for(int i = 0; i < N - P; i++){
        Ans.pb('0');
    }
    reverse(Ans.begin(), Ans.end());
    return Ans;
}

void Solve(int X){
    Used[X] = true;
    Ans.pb(X);
    Cnt++;
    if(Cnt == (1 << N)){
        cout << Ans.size() << '\n';
        for(int i : Ans){
            cout << rev(i) << '\n';
        }
        exit(0);
    }
    for(int i : tran){
        if(!Used[i ^ X]){
            Solve(i ^ X);
        }
    }
}

int main() {
    Kultivator;
    string S;
    cin >> N >> K >> T >> S;
    if(K % 2 == 0) return cout << -1, 0;
    for(int mask = 0; mask < (1 << N); mask++){
        if(__builtin_popcount(mask) == K){
            tran.pb(mask);
        }
    }
    Solve(bom(S));
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 492 KB First number in answer is not x 1 2
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 1 ms 364 KB Ok
3 Correct 1 ms 364 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 1 ms 364 KB Ok
8 Correct 1 ms 400 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 99 ms 43752 KB Ok
2 Correct 47 ms 21996 KB Ok
3 Correct 1 ms 492 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 3 ms 1644 KB Ok
3 Correct 47 ms 21992 KB Ok
4 Correct 23 ms 11116 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 2 ms 620 KB Ok
7 Correct 12 ms 5740 KB Ok
8 Correct 1 ms 364 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 98 ms 43936 KB First number in answer is not x 44202 87252
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 99 ms 43752 KB Ok
2 Correct 47 ms 21996 KB Ok
3 Correct 1 ms 492 KB Ok
4 Correct 1 ms 364 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 3 ms 1644 KB Ok
8 Correct 47 ms 21992 KB Ok
9 Correct 23 ms 11116 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 2 ms 620 KB Ok
12 Correct 12 ms 5740 KB Ok
13 Correct 1 ms 364 KB Ok
14 Incorrect 98 ms 43936 KB First number in answer is not x 44202 87252
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 48 ms 22124 KB First number in answer is not x 92826 45741
2 Halted 0 ms 0 KB -