Submission #45119

# Submission time Handle Problem Language Result Execution time Memory
45119 2018-04-11T10:13:18 Z model_code Norela (info1cup18_norela) C++17
100 / 100
134 ms 132064 KB
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cassert>

#define MOD (1<<13)

using namespace std;

long long a[32], dp[17200000];
int cnt[MOD + 100], led[MOD + 100];

void precalc ()
{
    for (int i = 0; i <= MOD + 5; ++i)
    {
        int ci = i;
        for (; ci > 0; ci >>= 1)
        {
            if (ci & 1) ++cnt[i];
            ++led[i];
        }
    }
}

int main ()
{
  //  freopen ("input", "r", stdin);
   // freopen ("output3", "w", stdout);

    int n, m;
    scanf ("%d %d", &n, &m);

    precalc ();

    assert (1 <= n && n <= 60);
    assert (1 <= m && m <= 24);

    for (int i = 1; i <= m; ++i)
    {
        int q;
        scanf ("%d", &q);

        assert (1 <= q && q <= n);

        for (int j = 1; j <= q; ++j)
        {
            int x;
            scanf ("%d", &x);

            assert (1 <= x && x <= n);

            a[m - i + 1] |= (1LL << (1LL * (x - 1)));
        }
    }

    int sol, mi = 400;
    for (int i = 1; i < (1 << m); ++i)
    {
        int bit;
        if (i >> 13) bit = led[i >> 13] + 13;
        else bit = led[i];

        dp[i] = (dp[i ^ (1 << (bit - 1))] ^ a[bit]);

        if (dp[i] == (1LL << (1LL * n)) - 1LL)
        {
            int x = cnt[i >> 13] + cnt[i & ((1 << 13) - 1)];
            if (mi >= x) mi = x, sol = i;
        }
    }

    printf ("%d\n", mi);
    assert (mi < 400);

    for (int j = m - 1; j >= 0; --j)
        if (sol & (1 << j)) printf ("%d ", m - j);

    printf ("\n");

    return 0;
}

Compilation message

norela.cpp: In function 'int main()':
norela.cpp:32:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d %d", &n, &m);
     ~~~~~~^~~~~~~~~~~~~~~~~
norela.cpp:42:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d", &q);
         ~~~~~~^~~~~~~~~~
norela.cpp:49:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf ("%d", &x);
             ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2424 KB Output is correct
2 Correct 4 ms 2532 KB Output is correct
3 Correct 2 ms 2532 KB Output is correct
4 Correct 4 ms 2732 KB Output is correct
5 Correct 5 ms 2732 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2424 KB Output is correct
2 Correct 4 ms 2532 KB Output is correct
3 Correct 2 ms 2532 KB Output is correct
4 Correct 4 ms 2732 KB Output is correct
5 Correct 5 ms 2732 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
7 Correct 11 ms 8728 KB Output is correct
8 Correct 18 ms 17084 KB Output is correct
9 Correct 19 ms 17084 KB Output is correct
10 Correct 18 ms 17084 KB Output is correct
11 Correct 17 ms 17084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2424 KB Output is correct
2 Correct 4 ms 2532 KB Output is correct
3 Correct 2 ms 2532 KB Output is correct
4 Correct 4 ms 2732 KB Output is correct
5 Correct 5 ms 2732 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
7 Correct 11 ms 8728 KB Output is correct
8 Correct 18 ms 17084 KB Output is correct
9 Correct 19 ms 17084 KB Output is correct
10 Correct 18 ms 17084 KB Output is correct
11 Correct 17 ms 17084 KB Output is correct
12 Correct 18 ms 17084 KB Output is correct
13 Correct 34 ms 33472 KB Output is correct
14 Correct 40 ms 33472 KB Output is correct
15 Correct 36 ms 33472 KB Output is correct
16 Correct 34 ms 33472 KB Output is correct
17 Correct 34 ms 33472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2424 KB Output is correct
2 Correct 4 ms 2532 KB Output is correct
3 Correct 2 ms 2532 KB Output is correct
4 Correct 4 ms 2732 KB Output is correct
5 Correct 5 ms 2732 KB Output is correct
6 Correct 4 ms 2732 KB Output is correct
7 Correct 11 ms 8728 KB Output is correct
8 Correct 18 ms 17084 KB Output is correct
9 Correct 19 ms 17084 KB Output is correct
10 Correct 18 ms 17084 KB Output is correct
11 Correct 17 ms 17084 KB Output is correct
12 Correct 18 ms 17084 KB Output is correct
13 Correct 34 ms 33472 KB Output is correct
14 Correct 40 ms 33472 KB Output is correct
15 Correct 36 ms 33472 KB Output is correct
16 Correct 34 ms 33472 KB Output is correct
17 Correct 34 ms 33472 KB Output is correct
18 Correct 66 ms 66208 KB Output is correct
19 Correct 86 ms 66284 KB Output is correct
20 Correct 132 ms 131948 KB Output is correct
21 Correct 133 ms 131964 KB Output is correct
22 Correct 133 ms 131988 KB Output is correct
23 Correct 134 ms 132064 KB Output is correct