# Codeforces 101206 H & HDU 6006 Engineer Assignment

1N,M10$1\leq N,M \leq 10$

1C100$1\leq C \leq 100$

1A,B3$1\leq A,B \leq 3$

dp[N][1<<M]

dp[i][j]=MIN(dp[i][j],dp[i1][k|up]+1)

#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<vector>
#include <functional>
using namespace std;

typedef long long ll;
typedef pair<ll, ll>pii;
typedef bitset<101> bs;

#define sp system("pause")

bs p[15], e[15];
vector<int>pw[15];
int dp[15][(1 << 13)];

void init()
{
memset(dp, -1, sizeof dp);
for (int i = 0; i < 15; i++)p[i].reset(), e[i].reset(),pw[i].clear();
}

int main()
{
int T;
cin >> T;
int cas = 1;
while (T--)
{
init();
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++)
{
int x;
scanf("%d", &x);
for (int j = 0; j < x; j++)
{
int y;
scanf("%d", &y);
p[i][y] = 1;
}
}
for (int i = 0; i < m; i++)
{
int x;
scanf("%d", &x);
for (int j = 0; j < x; j++)
{
int y;
scanf("%d", &y);
e[i][y] = 1;
}
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < (1 << m); j++)
{
bs now;
for (int k = 0; k < m; k++)if (j&(1 << k))now |= e[k];
if ((now&p[i]) == p[i])pw[i].push_back(j);
}
}
for (int i = 0; i < pw[0].size(); i++)
dp[0][pw[0][i]] = 1;
for (int i = 0; i < (1 << m); i++)if (dp[0][i] == -1)dp[0][i] = 0;
int ans = 0;
for (int i = 1; i < n; i++)
{
for (int j = 0; j < (1 << m); j++)
{
if (dp[i - 1][j] == -1)continue;
if (dp[i][j] == -1)dp[i][j] = dp[i - 1][j];
else dp[i][j] = max(dp[i][j], dp[i - 1][j]);
for (int k = 0; k < pw[i].size(); k++)
{
int now = pw[i][k];
if ((now&j) == 0)
{
if (dp[i][now | j] == -1)dp[i][now | j] = dp[i - 1][j] + 1;
else dp[i][now | j] = max(dp[i][now | j], dp[i - 1][j] + 1);
}
}
}
}
for (int i = 0; i < n; i++)for (int j = 0; j < (1 << m); j++)
ans = max(ans, dp[i][j]);
printf("Case #%d: %d\n", cas++, ans);
}
}

10-02 189

07-02 932

11-14 213

09-30 195

10-21 27

07-31 5158

07-30 8160

#### YOLO系列算法精讲：从yolov1至yolov4的进阶之路（呕心沥血2万字超全整理，建议收藏！）

©️2020 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。