답안 #505127

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
505127 2022-01-10T15:58:17 Z leaked "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
64 ms 6444 KB
//#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define f first
#define s second
#define vec vector
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pw(x) (1LL<<(x))
#define sz(x) (int)(x).size()
#define fast_izho ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define m_p make_pair
using namespace std;
template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);}
template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
auto rng=bind(uniform_int_distribution<int>(1,1e7),mt19937(time(0)));

signed main(){
    fast_izho;
//    ifstream cin("input.txt");
    int n,k,t;
    cin>>n>>k>>t;
    n=pw(n);
    vec<int> base,elim;
    for(int i=0;i<n;i++){
        if(__builtin_popcount(i)==k){
            int x=i;
            for(auto &z : elim) x=min(x,x^z);
            if(x){
                base.pb(i);
                elim.pb(x);
            }
        }
    }
    if(sz(base)!=(__builtin_popcount(n-1))){
        cout<<-1;
        return 0;
    }
    int xr=0;
    vec<int>ans;
    ans.pb(0);
    for(int i=1;i<n;i++){
//        cout<<xr<<' ';
        xr^=base[31-__builtin_clz(i&-i)];
        ans.pb(xr);

//        cout<<xr<<'\n';
    }
//    int s;
    string s;
    cin>>s;
    int x=0;
    for(auto &z : s)
        x*=2,x+=(z-'0');
//    int x=stoi(s);
//    cin>>s;
//    cout<<x<<endl;
//    cout<<ans[0]<<endl;
    for(auto &z : ans)
        z^=x;
    for(int i=0;i<n;i++){
        int j=(i+1)%n;
        if(i==n-1 && t==0) continue;
        if(__builtin_popcount(ans[i]^ans[j])!=k){
            cout<<-1;
            return 0;
        }
    }
    int need=__builtin_popcount(n-1);
    cout<<n<<'\n';
    for(auto &z : ans){
        string me;
        for(int j=0;j<need;j++){
            me+=(pw(j)&z?'1':'0');
        }
        reverse(all(me));
        cout<<me<<'\n';
    }
    return 0;
}
/*
5 1
0 1 1 3 2
1 3
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 204 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 204 KB Ok
6 Correct 0 ms 204 KB Ok
7 Correct 1 ms 204 KB Ok
8 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 6360 KB Ok
2 Correct 27 ms 3268 KB Ok
3 Correct 1 ms 296 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 320 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Ok
2 Correct 2 ms 448 KB Ok
3 Correct 27 ms 3252 KB Ok
4 Correct 14 ms 1744 KB Ok
5 Correct 1 ms 332 KB Ok
6 Correct 1 ms 320 KB Ok
7 Correct 6 ms 1040 KB Ok
8 Correct 0 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 58 ms 6368 KB Ok
2 Correct 64 ms 6380 KB Ok
3 Correct 60 ms 6372 KB Ok
4 Correct 27 ms 3268 KB Ok
5 Correct 27 ms 3264 KB Ok
6 Correct 13 ms 1736 KB Ok
7 Correct 15 ms 1744 KB Ok
8 Correct 7 ms 1100 KB Ok
9 Correct 6 ms 1084 KB Ok
10 Correct 3 ms 588 KB Ok
11 Correct 1 ms 312 KB Ok
12 Correct 1 ms 324 KB Ok
13 Correct 1 ms 204 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 56 ms 6360 KB Ok
2 Correct 27 ms 3268 KB Ok
3 Correct 1 ms 296 KB Ok
4 Correct 1 ms 204 KB Ok
5 Correct 1 ms 320 KB Ok
6 Correct 0 ms 208 KB Ok
7 Correct 2 ms 448 KB Ok
8 Correct 27 ms 3252 KB Ok
9 Correct 14 ms 1744 KB Ok
10 Correct 1 ms 332 KB Ok
11 Correct 1 ms 320 KB Ok
12 Correct 6 ms 1040 KB Ok
13 Correct 0 ms 204 KB Ok
14 Correct 58 ms 6368 KB Ok
15 Correct 64 ms 6380 KB Ok
16 Correct 60 ms 6372 KB Ok
17 Correct 27 ms 3268 KB Ok
18 Correct 27 ms 3264 KB Ok
19 Correct 13 ms 1736 KB Ok
20 Correct 15 ms 1744 KB Ok
21 Correct 7 ms 1100 KB Ok
22 Correct 6 ms 1084 KB Ok
23 Correct 3 ms 588 KB Ok
24 Correct 1 ms 312 KB Ok
25 Correct 1 ms 324 KB Ok
26 Correct 1 ms 204 KB Ok
27 Correct 60 ms 6388 KB Ok
28 Correct 27 ms 3332 KB Ok
29 Correct 59 ms 6424 KB Ok
30 Correct 3 ms 680 KB Ok
31 Correct 1 ms 332 KB Ok
32 Correct 1 ms 440 KB Ok
33 Correct 7 ms 1000 KB Ok
34 Correct 1 ms 204 KB Ok
35 Correct 1 ms 204 KB Ok
36 Correct 1 ms 332 KB Ok
37 Correct 1 ms 320 KB Ok
38 Correct 29 ms 3232 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 3276 KB Ok
2 Correct 61 ms 6444 KB Ok
3 Correct 60 ms 6436 KB Ok
4 Correct 3 ms 588 KB Ok
5 Correct 0 ms 332 KB Ok
6 Correct 6 ms 1100 KB Ok
7 Correct 55 ms 6376 KB Ok
8 Correct 1 ms 332 KB Ok
9 Correct 1 ms 204 KB Ok
10 Correct 1 ms 332 KB Ok
11 Correct 14 ms 1792 KB Ok
12 Correct 28 ms 3324 KB Ok