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 |
有没不用Floyd 做的啊.........网上翻了半天都是一样的...小弟代码如下 希望指点一下#include<iostream> using namespace std; int a[111][111]; int n,m; void find(int i,int j) { int k; if(a[i][j]==0) { a[i][j]=1; a[j][i]=-1; a[i][0]++; a[j][0]++; } for(k=1;k<=n;k++) { if(a[i][k]==-1) { if(a[j][k]==0) { a[k][j]=1; a[j][k]=-1; a[j][0]++; a[k][0]++; } } } for(k=1;k<=n;k++) { if(a[j][k]==1) { if(a[i][k]==0) { a[k][i]=-1; a[i][k]=1; a[i][0]++; a[k][0]++; } } } } int main() { int i,j,ii,num,k; freopen("test.txt","r",stdin); memset(a,0,sizeof(a)); cin>>n>>m; for(ii=1;ii<=m;ii++) { cin>>i>>j; find(i,j); } num=0; for(k=1;k<=n;k++) { if(a[k][0]==n-1) { num++; cout<<k<<" "; } } cout<<endl; cout<<num<<endl; return 1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator