답안 #345161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
345161 2021-01-07T05:39:10 Z koketsu "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
116 ms 44068 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 = 0; i < S.size(); i++){
        Ans += ((S[i] - '0') << (S.size() - i - 1));
    }
    return Ans;
}

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

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));
    //cout << bom(S);
}

Compilation message

lyuboyn.cpp: In function 'int bom(std::string)':
lyuboyn.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int i = 0; i < S.size(); i++){
      |                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 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 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 43852 KB Ok
2 Correct 55 ms 21996 KB Ok
3 Correct 1 ms 640 KB Ok
4 Correct 1 ms 504 KB Ok
5 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Ok
2 Correct 3 ms 1664 KB Ok
3 Correct 52 ms 21992 KB Ok
4 Correct 30 ms 11228 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 620 KB Ok
7 Correct 12 ms 5740 KB Ok
8 Correct 1 ms 364 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 110 ms 43928 KB Ok
2 Correct 100 ms 43872 KB Ok
3 Correct 100 ms 43748 KB Ok
4 Correct 49 ms 22184 KB Ok
5 Correct 60 ms 21992 KB Ok
6 Correct 25 ms 11240 KB Ok
7 Correct 26 ms 11120 KB Ok
8 Correct 11 ms 5740 KB Ok
9 Correct 11 ms 5868 KB Ok
10 Correct 6 ms 3056 KB Ok
11 Correct 1 ms 492 KB Ok
12 Correct 1 ms 492 KB Ok
13 Correct 1 ms 400 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 43852 KB Ok
2 Correct 55 ms 21996 KB Ok
3 Correct 1 ms 640 KB Ok
4 Correct 1 ms 504 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 1 ms 364 KB Ok
7 Correct 3 ms 1664 KB Ok
8 Correct 52 ms 21992 KB Ok
9 Correct 30 ms 11228 KB Ok
10 Correct 1 ms 364 KB Ok
11 Correct 1 ms 620 KB Ok
12 Correct 12 ms 5740 KB Ok
13 Correct 1 ms 364 KB Ok
14 Correct 110 ms 43928 KB Ok
15 Correct 100 ms 43872 KB Ok
16 Correct 100 ms 43748 KB Ok
17 Correct 49 ms 22184 KB Ok
18 Correct 60 ms 21992 KB Ok
19 Correct 25 ms 11240 KB Ok
20 Correct 26 ms 11120 KB Ok
21 Correct 11 ms 5740 KB Ok
22 Correct 11 ms 5868 KB Ok
23 Correct 6 ms 3056 KB Ok
24 Correct 1 ms 492 KB Ok
25 Correct 1 ms 492 KB Ok
26 Correct 1 ms 400 KB Ok
27 Correct 105 ms 43676 KB Ok
28 Correct 59 ms 22000 KB Ok
29 Correct 105 ms 43888 KB Ok
30 Correct 6 ms 3052 KB Ok
31 Correct 1 ms 496 KB Ok
32 Correct 3 ms 1644 KB Ok
33 Correct 12 ms 5868 KB Ok
34 Correct 1 ms 364 KB Ok
35 Correct 1 ms 364 KB Ok
36 Correct 1 ms 364 KB Ok
37 Correct 1 ms 364 KB Ok
38 Correct 51 ms 21996 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 21996 KB Ok
2 Correct 105 ms 43752 KB Ok
3 Correct 109 ms 44068 KB Ok
4 Correct 7 ms 3200 KB Ok
5 Correct 1 ms 364 KB Ok
6 Correct 11 ms 5740 KB Ok
7 Correct 102 ms 43744 KB Ok
8 Correct 1 ms 528 KB Ok
9 Correct 1 ms 364 KB Ok
10 Correct 1 ms 492 KB Ok
11 Correct 33 ms 11120 KB Ok
12 Correct 50 ms 22000 KB Ok