Submission #498835

# Submission time Handle Problem Language Result Execution time Memory
498835 2021-12-26T12:39:55 Z nickmet2004 "The Lyuboyn" code (IZhO19_lyuboyn) C++11
100 / 100
574 ms 28368 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5;
int n , k , T , M,ok;
string s;
int vis[N];
vector<int> ans,v;
void go(int x){
    ans.emplace_back(x);
    if(ans.size()==(1<<n) &&__builtin_popcount(ans[0] ^ ans.back())==k){
        cout<<(1<<n)<<endl;
        for(int i = 0; i < ans.size();++i){
            for(int j = n-1; ~j; --j)cout << (ans[i]>>j&1);cout<<endl;
        }
        exit(0);
    }
    vis[x]=1;
    for(int y : v){
        if(!vis[x^y])go(x^y);
    }
}
 main (){
ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n>>k>>T>>s;
    for(int i= 0; i < (1<<n); ++i){
        if(__builtin_popcount(i)==k){
            v.emplace_back(i);
        }
    }
    if(k%2==0){cout<<-1;return 0;}
    int X= 0;
    for(int i = 0; i< s.size(); ++i){
        if(s[i]=='1')X+=(1<<(s.size()-i-1));
    }
   go(X);
   cout<<-1<<endl;

}

Compilation message

lyuboyn.cpp: In function 'void go(int)':
lyuboyn.cpp:10:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   10 |     if(ans.size()==(1<<n) &&__builtin_popcount(ans[0] ^ ans.back())==k){
      |        ~~~~~~~~~~^~~~~~~~
lyuboyn.cpp:12:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for(int i = 0; i < ans.size();++i){
      |                        ~~^~~~~~~~~~~~
lyuboyn.cpp:13:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   13 |             for(int j = n-1; ~j; --j)cout << (ans[i]>>j&1);cout<<endl;
      |             ^~~
lyuboyn.cpp:13:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   13 |             for(int j = n-1; ~j; --j)cout << (ans[i]>>j&1);cout<<endl;
      |                                                            ^~~~
lyuboyn.cpp: At global scope:
lyuboyn.cpp:22:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 |  main (){
      |  ^~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 0; i< s.size(); ++i){
      |                    ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Ok
2 Correct 1 ms 204 KB Ok
3 Correct 1 ms 460 KB Ok
4 Correct 0 ms 204 KB Ok
5 Correct 0 ms 204 KB Ok
6 Correct 0 ms 204 KB Ok
7 Correct 1 ms 332 KB Ok
8 Correct 1 ms 332 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 545 ms 28108 KB Ok
2 Correct 256 ms 14080 KB Ok
3 Correct 4 ms 336 KB Ok
4 Correct 0 ms 208 KB Ok
5 Correct 1 ms 208 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Ok
2 Correct 14 ms 1100 KB Ok
3 Correct 250 ms 14008 KB Ok
4 Correct 123 ms 7112 KB Ok
5 Correct 1 ms 332 KB Ok
6 Correct 4 ms 460 KB Ok
7 Correct 61 ms 3664 KB Ok
8 Correct 1 ms 332 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 525 ms 28052 KB Ok
2 Correct 574 ms 28116 KB Ok
3 Correct 512 ms 28032 KB Ok
4 Correct 257 ms 14144 KB Ok
5 Correct 249 ms 14008 KB Ok
6 Correct 124 ms 7140 KB Ok
7 Correct 132 ms 7212 KB Ok
8 Correct 57 ms 3708 KB Ok
9 Correct 59 ms 3788 KB Ok
10 Correct 31 ms 1972 KB Ok
11 Correct 3 ms 336 KB Ok
12 Correct 2 ms 336 KB Ok
13 Correct 1 ms 336 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 545 ms 28108 KB Ok
2 Correct 256 ms 14080 KB Ok
3 Correct 4 ms 336 KB Ok
4 Correct 0 ms 208 KB Ok
5 Correct 1 ms 208 KB Ok
6 Correct 1 ms 204 KB Ok
7 Correct 14 ms 1100 KB Ok
8 Correct 250 ms 14008 KB Ok
9 Correct 123 ms 7112 KB Ok
10 Correct 1 ms 332 KB Ok
11 Correct 4 ms 460 KB Ok
12 Correct 61 ms 3664 KB Ok
13 Correct 1 ms 332 KB Ok
14 Correct 525 ms 28052 KB Ok
15 Correct 574 ms 28116 KB Ok
16 Correct 512 ms 28032 KB Ok
17 Correct 257 ms 14144 KB Ok
18 Correct 249 ms 14008 KB Ok
19 Correct 124 ms 7140 KB Ok
20 Correct 132 ms 7212 KB Ok
21 Correct 57 ms 3708 KB Ok
22 Correct 59 ms 3788 KB Ok
23 Correct 31 ms 1972 KB Ok
24 Correct 3 ms 336 KB Ok
25 Correct 2 ms 336 KB Ok
26 Correct 1 ms 336 KB Ok
27 Correct 541 ms 27988 KB Ok
28 Correct 254 ms 14036 KB Ok
29 Correct 542 ms 28044 KB Ok
30 Correct 31 ms 2016 KB Ok
31 Correct 3 ms 336 KB Ok
32 Correct 16 ms 1092 KB Ok
33 Correct 60 ms 3740 KB Ok
34 Correct 1 ms 320 KB Ok
35 Correct 1 ms 208 KB Ok
36 Correct 2 ms 336 KB Ok
37 Correct 0 ms 320 KB Ok
38 Correct 289 ms 14204 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 254 ms 13988 KB Ok
2 Correct 528 ms 27968 KB Ok
3 Correct 556 ms 28368 KB Ok
4 Correct 39 ms 2000 KB Ok
5 Correct 1 ms 336 KB Ok
6 Correct 65 ms 3712 KB Ok
7 Correct 527 ms 27960 KB Ok
8 Correct 2 ms 336 KB Ok
9 Correct 1 ms 208 KB Ok
10 Correct 2 ms 324 KB Ok
11 Correct 137 ms 7204 KB Ok
12 Correct 256 ms 14100 KB Ok