Submission #1306593

#TimeUsernameProblemLanguageResultExecution timeMemory
1306593Robert_junior"The Lyuboyn" code (IZhO19_lyuboyn)C++20
100 / 100
992 ms36712 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
vector<int>v;
int n, k, t, s;
bool used[(1<<18)];
vector<int>ord;
void dfs(int x, int i){
    if(i == (1<<n) - 1){
        if(t == 1){
            if(__builtin_popcount((s ^ ord.back())) != k) return;
            if(__builtin_popcount((s ^ ord[0])) != k) return;
        }
        cout<<(1<<n)<<'\n';
        for(int j = 0; j < n; j++) cout<<((s>>j) & 1);
            cout<<'\n';
        for(auto it : ord){
            for(int j = 0; j < n; j++) cout<<((it>>j) & 1);
            cout<<'\n';
        }
        exit(0);
    }
    else{
        for(auto it : v){
            if(!used[(it ^ x)]){
                used[(it ^ x)] = 1;
                ord.pb((it ^ x));
                dfs((it ^ x), i + 1);
            }
        }
    }
}
void solve(){
    cin>>n>>k>>t;
    for(int i = 0; i < n; i++){
        char c;
        cin>>c;
        if(c == '1') s |= (1<<i);
    }
    for(int msk = 0; msk < (1<<n); msk++){
        if(__builtin_popcount(msk) != k) continue;
        v.pb(msk);
    }
    used[s] = 1;
    dfs(s, 0);
    cout<<-1;
}
main(){
    solve();
}

Compilation message (stderr)

lyuboyn.cpp:52:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main(){
      | ^~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...