Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
y放代码在这里#include<iostream> #include<queue> #include<cstdio> #include<cstring> #include<algorithm> #define maxn 105 using namespace std; int n,m; int ans=0; int maz[maxn][maxn]; void floyd() { for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) if(maz[i][k]) for(int j=1;j<=n;j++) { if(!maz[k][j]||maz[i][j]) continue; if(maz[i][k]==1&&maz[k][j]==1) { maz[i][j]=1; maz[j][i]=-1; } else if(maz[i][k]==-1&&maz[k][j]==-1) { maz[i][j]=-1; maz[j][i]=1; } } } int main() { int i,j,u,v; scanf("%d%d",&n,&m); memset(maz,0,sizeof(maz)); for(i=0;i<m;i++) { scanf("%d%d",&u,&v); maz[u][v]=1; maz[v][u]=-1; } floyd(); ans=0; for(i=1;i<=n;i++) { int sum=0; for(j=1;j<=n;j++) if(maz[i][j]) sum++; if(sum==n-1) ans++; } printf("%d\n",ans); return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator