제출 #498835

#제출 시각아이디문제언어결과실행 시간메모리
498835nickmet2004"The Lyuboyn" code (IZhO19_lyuboyn)C++11
100 / 100
574 ms28368 KiB
#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;

}

컴파일 시 표준 에러 (stderr) 메시지

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 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...