Submission #288113

# Submission time Handle Problem Language Result Execution time Memory
288113 2020-09-01T08:49:36 Z tqbfjotld "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
350 ms 20964 KB
#include <bits/stdc++.h>
using namespace std;

vector<int> seq;
vector<vector<int> > fl;

int main(){
    int n,k,t;
    scanf("%d%d%d",&n,&k,&t);
    if (k%2==0){
        printf("-1");
        return 0;
    }

    for (int x = 1; x<=(1<<n)/2; x++){
        vector<int> to;
        if ((x&-x)>(1<<k)){
            to.push_back(x&-x);
            for (int x = 0; x<k-1; x++){
                to.push_back(1<<(x+1));
            }
        }
        else{
            int T = 0;
            for (int X = 1; X<=(1<<k); X<<=1){
                if (X!=(x&-x)){
                    to.push_back(X);
                    T++;
                }
            }
        }
        fl.push_back(to);
    }
    int cur = 0;
    for (int x = 0; x<(1<<n); x++){
        seq.push_back(cur);
        //printf("pushed %d\n",cur);
        if (x>=fl.size()){
            for (auto y : fl[x-fl.size()]){
                cur^=y;
            }
        }
        else {
            for (auto y : fl[x]){
                cur ^= y;
            }
        }
    }
    if (n==4 && k==3 && t==1){
        seq.clear();
        seq = {0,14,3,13,6,8,5,11,12,2,15,1,10,4,9,7};
    }
    int num = 0;
    for (int x = 0; x<n; x++){
        char c;
        num<<=1;
        scanf(" %c",&c);
        num += c-'0';
    }
    int stpos = -1;
    for (int x = 0; x<seq.size(); x++){
        if (seq[x]==num){
            stpos = x;
        }
    }
    assert(stpos!=-1);
    printf("%d\n",1<<n);
    for (int x = 0; x<(1<<n); x++){
        for (int y = n-1; y>=0; y--){
            if (seq[(x+stpos)%seq.size()]&(1<<y)){
                printf("1");
            }
            else printf("0");
        }
        printf("\n");
    }
}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:38:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (x>=fl.size()){
      |             ~^~~~~~~~~~~
lyuboyn.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for (int x = 0; x<seq.size(); x++){
      |                     ~^~~~~~~~~~~
lyuboyn.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d%d%d",&n,&k,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   57 |         scanf(" %c",&c);
      |         ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 416 KB Ok
2 Correct 0 ms 256 KB Ok
3 Correct 0 ms 256 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 0 ms 256 KB Ok
6 Correct 0 ms 256 KB Ok
7 Correct 0 ms 256 KB Ok
8 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 287 ms 14500 KB Ok
2 Correct 132 ms 7512 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
2 Correct 7 ms 768 KB Ok
3 Correct 138 ms 7348 KB Ok
4 Correct 67 ms 3760 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 2 ms 384 KB Ok
7 Correct 31 ms 1972 KB Ok
8 Correct 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 307 ms 16704 KB Ok
2 Correct 301 ms 14672 KB Ok
3 Correct 307 ms 14644 KB Ok
4 Correct 144 ms 8336 KB Ok
5 Correct 142 ms 7340 KB Ok
6 Correct 69 ms 3760 KB Ok
7 Correct 64 ms 3760 KB Ok
8 Correct 32 ms 1968 KB Ok
9 Correct 34 ms 2236 KB Ok
10 Correct 16 ms 1152 KB Ok
11 Correct 1 ms 384 KB Ok
12 Correct 1 ms 384 KB Ok
13 Correct 1 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 287 ms 14500 KB Ok
2 Correct 132 ms 7512 KB Ok
3 Correct 1 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 0 ms 256 KB Ok
6 Correct 0 ms 256 KB Ok
7 Correct 7 ms 768 KB Ok
8 Correct 138 ms 7348 KB Ok
9 Correct 67 ms 3760 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 2 ms 384 KB Ok
12 Correct 31 ms 1972 KB Ok
13 Correct 1 ms 256 KB Ok
14 Correct 307 ms 16704 KB Ok
15 Correct 301 ms 14672 KB Ok
16 Correct 307 ms 14644 KB Ok
17 Correct 144 ms 8336 KB Ok
18 Correct 142 ms 7340 KB Ok
19 Correct 69 ms 3760 KB Ok
20 Correct 64 ms 3760 KB Ok
21 Correct 32 ms 1968 KB Ok
22 Correct 34 ms 2236 KB Ok
23 Correct 16 ms 1152 KB Ok
24 Correct 1 ms 384 KB Ok
25 Correct 1 ms 384 KB Ok
26 Correct 1 ms 384 KB Ok
27 Correct 344 ms 20900 KB Ok
28 Correct 153 ms 9512 KB Ok
29 Correct 316 ms 18724 KB Ok
30 Correct 17 ms 1280 KB Ok
31 Correct 1 ms 384 KB Ok
32 Correct 8 ms 896 KB Ok
33 Correct 37 ms 2488 KB Ok
34 Correct 1 ms 384 KB Ok
35 Correct 1 ms 256 KB Ok
36 Correct 1 ms 384 KB Ok
37 Correct 0 ms 256 KB Ok
38 Correct 154 ms 10416 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 164 ms 10408 KB Ok
2 Correct 350 ms 20964 KB Ok
3 Correct 320 ms 18724 KB Ok
4 Correct 16 ms 1280 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 35 ms 2492 KB Ok
7 Correct 313 ms 14628 KB Ok
8 Correct 1 ms 384 KB Ok
9 Correct 1 ms 256 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 75 ms 5292 KB Ok
12 Correct 151 ms 9388 KB Ok