/*Author :usedrose */ /*Created Time :2015/8/27 1:45:04*/ /*File Name :2.cpp*/ #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <iostream> #include <algorithm> #include <sstream> #include <cstdlib> #include <cstring> #include <climits> #include <vector> #include <string> #include <ctime> #include <cmath> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #define INF 0x3f3f3f3f #define eps 1e-8 #define pi acos(-1.0) #define MAXN 1110 #define MAXM 11 #define OK cout << "ok" << endl; #define o(a) cout << #a << " = " << a << endl #define o1(a,b) cout << #a << " = " << a << " " << #b << " = " << b << endl using namespace std; typedef long long LL; int n, m, msk; int c[MAXM], cnt[1033]; int main() { //freopen("data.in","r",stdin); //freopen("data.out","w",stdout); cin.tie(0); ios::sync_with_stdio(false); while (cin >> n >> m) { init(); int x; for (int i = 0;i < n; ++ i) { msk = 0; for (int j = 0;j < m; ++ j) { cin >> x; if (x) msk |= (1<<j); } cnt[msk]++; } int nn = n; n = 1<<m; for (int i = 0;i <= (1<<m); ++ i) if (cnt[i]) { addedge(0, i, cnt[i]); for (int j = 0;j < 11; ++ j) { if ((1<<j)&i) addedge(i, n+j, INF); } } for (int i = 0;i < m; ++ i) { cin >> x; if (x) addedge(n+i, n+m, x); } //st = 0, en = n+m, point_num = n+m+1; if (nn == max_flow(0, n+m, n+m+1)) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }
时间: 2024-10-14 06:05:57