Submission #169454

#TimeUsernameProblemLanguageResultExecution timeMemory
169454SamAnd"The Lyuboyn" code (IZhO19_lyuboyn)C++17
100 / 100
131 ms19320 KiB
#include <bits/stdc++.h>
using namespace std;
const int N = 20;

int n, k, tt;

int a[1 << N];
bool c[1 << N];
vector<int> v;

void rec(int i)
{
    if (i == (1 << n))
    {
        printf("%d\n", (1 << n));
        for (int i = 0; i < (1 << n); ++i)
        {
            for (int j = 0; j < n; ++j)
            {
                if ((a[i] & (1 << j)))
                    putchar('1');
                else
                    putchar('0');
            }
            putchar('\n');
        }
        exit(0);
    }
    for (int j = 0; j < v.size(); ++j)
    {
        int x = (a[i - 1] ^ v[j]);
        if (!c[x])
        {
            c[x] = true;
            a[i] = x;
            rec(i + 1);
            c[x] = false;
        }
    }
}

int qan(int x)
{
    int q = 0;
    for (int i = 0; i < n; ++i)
    {
        if ((x & (1 << i)))
            ++q;
    }
    return q;
}

char s[N];
int main()
{
    //freopen("input.txt", "r", stdin);
    scanf("%d%d%d", &n, &k, &tt);
    for (int x = 0; x < (1 << n); ++x)
    {
        if (qan(x) == k)
            v.push_back(x);
    }
    scanf(" %s", s);
    if (k % 2 == 0)
    {
        printf("-1\n");
        return 0;
    }
    int x = 0;
    for (int i = 0; i < n; ++i)
    {
        if (s[i] == '1')
            x |= (1 << i);
    }
    a[0] = x;
    c[x] = true;
    rec(1);
    return 0;
}

Compilation message (stderr)

lyuboyn.cpp: In function 'void rec(int)':
lyuboyn.cpp:29:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j = 0; j < v.size(); ++j)
                     ~~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:57:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &k, &tt);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
lyuboyn.cpp:63:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %s", s);
     ~~~~~^~~~~~~~~~
#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...