1 int a[maxn][maxn]; 2 int linker[maxn]; 3 int cnt = 0; 4 bool dfs(int u) 5 { 6 _for(v,0,n) 7 if(a[u][v] && !used[v]) 8 { 9 used[v] = true; 10 if(linker[v] == -1 || dfs(linker[v])) 11 { 12 linker[v] = u; 13 return true; 14 } 15 } 16 return false; 17 } 18 int hungry() 19 { 20 int res = 0; 21 memset(linker,-1,sizeof(linker)); 22 _for(u,0,n) 23 { 24 memset(used,false,sizeof(used)); 25 if(dfs(u)) 26 res ++; 27 } 28 return res; 29 }