Submission #288250

# Submission time Handle Problem Language Result Execution time Memory
288250 2020-09-01T10:52:59 Z SomeoneUnknown "The Lyuboyn" code (IZhO19_lyuboyn) C++14
100 / 100
518 ms 5496 KB
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b){
    if(b>a) return gcd(b,a);
    if(b == 0) return a;
    return gcd(b, a%b);
}

int main(){
    int n, k, t;
    scanf("%d %d %d", &n, &k, &t);
    char s0[n+1];
    scanf("%s", &s0);
    bool s0b[n];
    for(int i = 0; i < n; ++i){
        s0b[i] = (s0[i] == '1');
    }
    if(/*gcd(n, k) != 1 ||*/ k%2 == 0){
        printf("-1");
        return 0;
    }
    printf("%d\n", 1 << n);
    printf("%s", s0);
    for(int i = 1; i < (1 << n); ++i){
        printf("\n");
        int sind = 0;
        int ti = i;
        while(ti % 2 == 0){
            ti >>= 1;
            sind++;
        }
        if(gcd(n,k) != 1){
            s0b[(sind + k) % n] = !s0b[(sind + k) % n];
            s0b[(sind + k-1) % n] = !s0b[(sind + k-1) % n];
        }
        for(int j = sind; j != (sind + k) % n; j = (j+1) % n){
            s0b[j] = !s0b[j];
        }
        for(int j = 0; j < n; ++j){
            printf("%d", s0b[j]);
        }
    }

}

Compilation message

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:14:13: warning: format '%s' expects argument of type 'char*', but argument 2 has type 'char (*)[(n + 1)]' [-Wformat=]
   14 |     scanf("%s", &s0);
      |            ~^   ~~~
      |             |   |
      |             |   char (*)[(n + 1)]
      |             char*
lyuboyn.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d %d %d", &n, &k, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%s", &s0);
      |     ~~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 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 0 ms 256 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 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 499 ms 5332 KB Ok
2 Correct 243 ms 2836 KB Ok
3 Correct 2 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 1 ms 256 KB Ok
2 Correct 12 ms 384 KB Ok
3 Correct 241 ms 2748 KB Ok
4 Correct 112 ms 1576 KB Ok
5 Correct 1 ms 384 KB Ok
6 Correct 3 ms 384 KB Ok
7 Correct 51 ms 888 KB Ok
8 Correct 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 518 ms 5340 KB Ok
2 Correct 499 ms 5408 KB Ok
3 Correct 488 ms 5368 KB Ok
4 Correct 232 ms 2680 KB Ok
5 Correct 229 ms 2680 KB Ok
6 Correct 113 ms 1528 KB Ok
7 Correct 107 ms 1400 KB Ok
8 Correct 51 ms 888 KB Ok
9 Correct 52 ms 888 KB Ok
10 Correct 25 ms 512 KB Ok
11 Correct 2 ms 376 KB Ok
12 Correct 2 ms 384 KB Ok
13 Correct 1 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 499 ms 5332 KB Ok
2 Correct 243 ms 2836 KB Ok
3 Correct 2 ms 384 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 0 ms 256 KB Ok
6 Correct 1 ms 256 KB Ok
7 Correct 12 ms 384 KB Ok
8 Correct 241 ms 2748 KB Ok
9 Correct 112 ms 1576 KB Ok
10 Correct 1 ms 384 KB Ok
11 Correct 3 ms 384 KB Ok
12 Correct 51 ms 888 KB Ok
13 Correct 1 ms 256 KB Ok
14 Correct 518 ms 5340 KB Ok
15 Correct 499 ms 5408 KB Ok
16 Correct 488 ms 5368 KB Ok
17 Correct 232 ms 2680 KB Ok
18 Correct 229 ms 2680 KB Ok
19 Correct 113 ms 1528 KB Ok
20 Correct 107 ms 1400 KB Ok
21 Correct 51 ms 888 KB Ok
22 Correct 52 ms 888 KB Ok
23 Correct 25 ms 512 KB Ok
24 Correct 2 ms 376 KB Ok
25 Correct 2 ms 384 KB Ok
26 Correct 1 ms 256 KB Ok
27 Correct 500 ms 5496 KB Ok
28 Correct 239 ms 2808 KB Ok
29 Correct 500 ms 5368 KB Ok
30 Correct 26 ms 512 KB Ok
31 Correct 2 ms 384 KB Ok
32 Correct 13 ms 384 KB Ok
33 Correct 54 ms 888 KB Ok
34 Correct 1 ms 256 KB Ok
35 Correct 1 ms 256 KB Ok
36 Correct 1 ms 256 KB Ok
37 Correct 0 ms 256 KB Ok
38 Correct 242 ms 2808 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 236 ms 2808 KB Ok
2 Correct 500 ms 5368 KB Ok
3 Correct 518 ms 5368 KB Ok
4 Correct 25 ms 512 KB Ok
5 Correct 1 ms 256 KB Ok
6 Correct 53 ms 888 KB Ok
7 Correct 487 ms 5368 KB Ok
8 Correct 2 ms 384 KB Ok
9 Correct 0 ms 256 KB Ok
10 Correct 2 ms 384 KB Ok
11 Correct 113 ms 1400 KB Ok
12 Correct 235 ms 2680 KB Ok