Submission #498817

# Submission time Handle Problem Language Result Execution time Memory
498817 2021-12-26T12:06:27 Z nickmet2004 "The Lyuboyn" code (IZhO19_lyuboyn) C++11
0 / 100
2 ms 820 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n , k , T;
string s;
int p;
 main (){
ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n>>k>>T>>s;
    vector<int> v;
    for(int i= 0; i < (1<<n); ++i){
        if(__builtin_popcount(i)==k){
            v.emplace_back(i);
        }
    }
    int X= 0;
    for(int i = 0; i< s.size(); ++i){
        if(s[i]=='1')X+=(1<<(s.size()-i-1));
    }
   // for(int x : v)cout <<x<<endl;
    int M = (1<<n)- 1;
    vector<int> ans;
    ans.emplace_back(X);
    int ok = 0;
    int y = X^v[0];
    ans.emplace_back(y);
    ans.emplace_back(y^v[1]);
    int b = 2;
    M-=2;
    int ab;
    for(int i = 0; i< M; ++i){
        if(p == v.size()){
            ok=1;break;
        }
        if(i&1^1){
            ab = ans.back()^v[p];
            ans.emplace_back(ab);
            ++p;
        }else{
            ab = ans.back()^v[b];
            ans.emplace_back(ab);
            ++b;
        }
    }
    if(ok){
        cout<<-1<<endl;return 0;
    }
    //for(int x : ans)cout <<x << " ";
    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;
    }

}

Compilation message

lyuboyn.cpp:7:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 |  main (){
      |  ^~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:17:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i< s.size(); ++i){
      |                    ~^~~~~~~~~~
lyuboyn.cpp:32:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         if(p == v.size()){
      |            ~~^~~~~~~~~~~
lyuboyn.cpp:35:13: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
   35 |         if(i&1^1){
      |            ~^~
lyuboyn.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(int i = 0; i < ans.size();++i){
      |                    ~~^~~~~~~~~~~~
lyuboyn.cpp:51:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   51 |         for(int j = n-1; ~j; --j)cout << (ans[i]>>j&1);cout<<endl;
      |         ^~~
lyuboyn.cpp:51:56: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   51 |         for(int j = n-1; ~j; --j)cout << (ans[i]>>j&1);cout<<endl;
      |                                                        ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Output -1 while solution exists
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Ok
2 Correct 1 ms 208 KB Ok
3 Correct 1 ms 700 KB Ok
4 Incorrect 0 ms 208 KB Found solution while it does not exist
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 820 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 312 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 320 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -