#include<iostream>
#include<vector>
#include<algorithm>
#include <string.h>
using namespace std;
const int M = 30;
int v, g;
int p[M];//v
int a[M][M];//g,v
bool st[M];
int temp[M];
bool ac[M];
int minP = 30;
int judge()
{
memset(temp, 0, sizeof(temp));
int x = 0;
for (int i = 0; i < g; i++)
{
if (st[i] == 1)
{
x += 1;
for (int j = 0; j < v; j++)
{
temp[j] += a[i][j];
}
}
}
for (int i = 0; i < v; i++)
{
if (temp[i] < p[i])
{
return -1;
}
}
return x;
}
void dfs(int u)
{
if (u == g)
{
int tempX = judge();
// cout<<tempX<<endl;
if (tempX != -1)
{
if (tempX < minP)
{
minP = tempX;
for (int i = 0; i < g; i++)
{
ac[i] = st[i];
}
}
if (tempX == minP)
{
for (int i = 0; i < g; i++)
{
if (ac[i] != st[i])
{
if(ac[i]==1)
{
break;
}
if (st[i] == 1)
{
for (in
洛谷 个人题解 P1460 [USACO2.1] 健康的荷斯坦奶牛 Healthy Holsteins
最新推荐文章于 2025-04-11 22:22:33 发布

537

被折叠的 条评论
为什么被折叠?



