int mp[maxn][maxn]; int book[maxn],vis[maxn],sum; bool dfs(int x) { for(int i=1;i<=m;i++) { if(mp[x][i]&&!vis[i]){ vis[i]=1; if(book[i]==0||dfs(book[i])){ book[i]=x; return 1; } } } return 0; } int solve() { int sum=0; memset(book,0,sizeof(book)); for(int i=1; i<=n; i++){ memset(vis,0,sizeof(vis)); if(dfs(i)) sum++; } return sum; }
时间: 2024-11-11 05:16:47