zoukankan      html  css  js  c++  java
  • bzoj1612: [Usaco2008 Jan]Cow Contest奶牛的比赛

    #include <bits/stdc++.h>
    #define eps 1e-8
    #define ll long long
    #define INF 2147483647
    #define ll_INF 9223372036854775807
    using namespace std;
    inline int read() {
    	int x = 0,tmp = 1;char ch = getchar();
    	while( ch < '0' || ch > '9' ) {if ( ch == '-' ) tmp = -1; ch = getchar();}
    	while( ch >= '0' && ch <= '9'){x = x * 10 + ch - '0'; ch = getchar(); }
    	return x * tmp;
    }
    bool _edge[110][110];
    int main() {
    	memset( _edge, 0, sizeof( _edge ) );
    	int N = read(), M = read();
    	for( int i = 1 ; i <= M ; ++ i ) {
    		int u = read(), v = read();
    		_edge[u][v] = 1;
    	}
    	for( int k = 1 ; k <= N ; ++ k )
    		for( int i = 1 ; i <= N ; ++ i )
    			for( int j = 1 ; j <= N ; ++ j )
    				_edge[i][j] = ( _edge[i][k] && _edge[k][j] ) || _edge[i][j];
    	
    	int ans = 0;
    	for( int i = 1 ; i <= N ; ++ i ) {
    		int cnt = 0;
    		for( int j = 1 ; j <= N ; ++ j ) cnt += _edge[j][i];
    		for( int j = 1 ; j <= N ; ++ j ) cnt += _edge[i][j];
    		ans += ( cnt == N - 1 );
    	} 
    	printf( "%d
    ", ans );
    
    	return 0;
    }
    
  • 相关阅读:
    14.7.1 重新调整InnoDB系统表空间的大小
    css代码引入方式与基本选择器
    html常用标签
    python数据库操作
    pt-osc使用一则
    mysql优化一则(20170703)
    进程与生产者消费者模型
    面向对象程序设计
    常用模块
    模块与包
  • 原文地址:https://www.cnblogs.com/ARZhu-NOIpAK/p/6641686.html
Copyright © 2011-2022 走看看