# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
45119 | model_code | Norela (info1cup18_norela) | C++17 | 134 ms | 132064 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |