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 |
3660#include <stdio.h> const int MAXN=100; int N, M,i,j,k; bool D[MAXN][MAXN]; int Res=0; int main () { scanf("%d%d", &N, &M); for(i=0;i<N;i++) D[i][i]=true; int a, b; for(i=0;i<M;i++) { scanf("%d%d", &a, &b); a--, b--; D[a][b]=true; } for(k=0;k<N;k++) for(i=0;i<N;i++) if (D[i][k]) for(j=0;j<N;j++) if (D[k][j]) D[i][j]=true; for(i=0;i<N;i++) { bool OK= true; for(j=0;j<N;j++) if (!D[i][j] && !D[j][i]) { OK= false; break; } if (OK) Res++; } printf("%d\n", Res); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator