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> #include<cstdio> using namespace std; #define maxn 32700 int main(){ int a[105][105]={0}; int m, n, i, j, k; cin>>n>>m; int x=0, y=0, s=0; while(m--){ cin>>i>>j; a[i][j] = 1; } for (i=1;i<=n;i++){ for(k=1;k<=n;k++){ if (a[i][k]){ for(j=1;j<=n;j++){ if (a[k][j]){ a[i][j]=1; } } } } } for (k=1;k<=n;k++){ x=0;y=0; for (i=1;i<=n;i++){ if (a[i][k]){ x++; //cout<<"x:"<<x<<endl; } } for (j=1;j<=n;j++){ if (a[k][j]){ y++; //cout<<"y:"<<y<<endl; } } if (x+y==n-1) s++; } cout<<s<<endl; system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator