/*at first, thought and Bzoj on the sacrifice is the same (after all, the same example) here do not know the adjacent points can reach each other indirectly connected can also be reached, so floyed first set up a relationship and then run the largest independent set of 95 and 100 below the code (carefully read the title to protect Peace)*/#include<iostream>#include<cstdio>#include<cstring>#defineMAXN 210#defineMAXM 30010using namespacestd;intN,M,HEAD[MAXN],NUM,ANS,MATCH[MAXN];BOOLF[MAXN];structnode{intU,v,pre;} E[MAXM];voidADD (int from,intTo ) {num++; E[NUM].U= from; E[NUM].V=to ; E[num].pre=head[ from]; head[ from]=num;}intDfs (ints) { for(intI=head[s];i;i=e[i].pre) { intv=e[i].v; if(f[v]==0) {F[v]=1; if(match[v]==0||Dfs (Match[v])) {Match[v]=s; return 1; } } } return 0;}intMain () {scanf ("%d%d", &n,&m);intx, y; for(intI=1; i<=m;i++) {scanf ("%d%d",&x,&y); ADD (x, y); } for(intI=1; i<=n;i++) {memset (F,0,sizeof(f)); Ans+=Dfs (i); } intp=n-ans; printf ("%d\n", p); return 0;}
#include <iostream>#include<cstdio>#include<cstring>#defineMAXN 210using namespacestd;intN,M,G[MAXN][MAXN],ANS,MATCH[MAXN];BOOLF[MAXN];intDfs (ints) { for(intI=1; i<=n;i++) if(f[i]==0&&g[s][i]==1) {F[i]=1; if(match[i]==0||Dfs (Match[i])) {Match[i]=s; return 1; } } return 0;}intMain () {scanf ("%d%d",&n,&m); intx,y;ans=N; for(intI=1; i<=m;i++) {scanf ("%d%d",&x,&y); G[x][y]=1; } for(intk=1; k<=n;k++) for(intI=1; i<=n;i++) for(intj=1; j<=n;j++) G[i][j]=g[i][j]| | (g[i][k]&&G[k][j]); for(intI=1; i<=n;i++) {memset (F,0,sizeof(f)); Ans-=Dfs (i); } printf ("%d\n", ans); return 0;}
Codevs 2494 Vani and Cl2 hide and seek