Hdu 2603过山车 二分图最大匹配匈牙利算法模板题

Ines ·
更新时间:2024-09-21
· 703 次阅读

 匈牙利算法模板题,稍微注意一下先输入m,再输入n,而且是单向边。

code:

#include #include #include #include #include #include #include #include #include #include #include #include #include #define IO \ ios::sync_with_stdio(false); \ // cin.tie(0); \ // cout.tie(0); using namespace std; typedef long long LL; const int maxn = 5e2 + 5; const int maxm = 1e6 + 10; const LL INF = 0x3f3f3f3f3f3f3f3f; const int inf = 0x3f3f3f3f; const LL mod = 998244353; int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0}; int a[maxn][maxn], vis[maxn], match[maxn]; int k, n, m; int DFS(int u) { for (int i = 1; i > k && k) { cin >> m >> n; int x, y; memset(a, 0, sizeof a); memset(match, 0, sizeof match); for (int i = 0; i > x >> y; a[x][y] = 1; // 单向边 // a[y][x] = 1; } int ans = 0; for (int i = 1; i <= m; i++) { memset(vis, 0, sizeof vis); if (DFS(i)) ans++; } cout << ans << endl; } return 0; } TTP1128 原创文章 90获赞 40访问量 1万+ 关注 私信 展开阅读全文
作者:TTP1128



hdu 二分图 模板 二分 算法

需要 登录 后方可回复, 如果你还没有账号请 注册新账号