For a dag, a person can take a path, or at a point (the path length is 0), ask how many people need to cover all the points.
Based on the nature of the bipartite graph:
Minimum path coverage of Dag. After each vertex is split, find the maximum number of matching m and the result is n-M. When finding a specific path, follow the matching edge, match edge I → j ', J → K', K → l '.... form a directed path.
#include<cstdio>#include<cstring>#include<cmath>#include<iostream>#include<algorithm>#include<vector>#include<queue>const int maxn=125;using namespace std;int mx[maxn],my[maxn],vis[maxn],e[maxn][maxn],n,m;int path(int u){ int i; for(i=1;i<=n;i++) { if(e[u][i]&&!vis[i]) { vis[i]=1; if(my[i]==-1||path(my[i])) { mx[u]=i; my[i]=u; return 1; } } } return 0;}int hungry(){ int res=0; memset(mx,-1,sizeof mx); memset(my,-1,sizeof my); for(int i=1;i<=n;i++) { if(mx[i]==-1) { memset(vis,0,sizeof vis); res+=path(i); } } return res;}int main(){ int ans,T,a,b,i; scanf("%d",&T); while(T--) { scanf("%d%d",&n,&m); memset(e,0,sizeof e); while(m--) { scanf("%d%d",&a,&b); e[a][b]=1; } ans=hungry(); printf("%d\n",n-ans); } return 0;}