题意

有n(1<=n<=100)个学生参加编程比赛。
给出m条实力信息。(1<=M<=4500)
其中每一条的格式为 A B (1<=A<=N,1<=B<=N,A!=B) 意思是A的实力比B强。
如果A比B强且B比C强,那么A一定比C强。
问最后有多少名学生可以确定他的排名。
保证输入信息不存在矛盾


题解

n<=100!!!

若A强于B则A向B连一条单向边
直接强行floyed判断连通性,如果这个点能到达的点数和能到达它的点数和为n-1则说明它的排名是确定的


常数巨大的代码

# include <stdio.h>
# include <stdlib.h>
# include <iostream>
# include <string.h>
# define IL inline
# define RG register
# define mem(a, b) memset(a, b, sizeof(a))
# define Max(a, b) (((a) > (b)) ? (a) : (b))
# define Min(a, b) (((a) < (b)) ? (a) : (b))
using namespace std; IL int Get(){
RG char c = '!'; RG int x = 0, z = 1;
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - '0';
return x * z;
} const int MAXN = 101;
int n, m, flag, ans, vis[MAXN], map[MAXN][MAXN]; int main(){
n = Get(); m = Get();
for(RG int i = 1; i <= m; i++)
map[Get()][Get()] = 1;
for(RG int k = 1; k <= n; k++)
for(RG int i = 1; i <= n; i++)
for(RG int j = 1; j <= n; j++)
map[i][j] |= (map[i][k] & map[k][j]);
for(RG int i = 1; i <= n; i++)
for(RG int j = 1; j <= n; j++)
vis[j] += map[i][j], vis[i] += map[i][j];
for(RG int i = 1; i <= n; i++)
ans += (vis[i] == n - 1);
printf("%d\n", ans);
return 0;
}

Cow Contest POJ - 3660的更多相关文章

  1. Cow Contest POJ - 3660 (floyd 传递闭包)

    N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...

  2. Cow Contest POJ - 3660 floyd传递闭包

    #include<iostream> #include<cstring> using namespace std; ,INF=0x3f3f3f3f; int f[N][N]; ...

  3. POJ - 3660 Cow Contest 传递闭包floyed算法

    Cow Contest POJ - 3660 :http://poj.org/problem?id=3660   参考:https://www.cnblogs.com/kuangbin/p/31408 ...

  4. POJ 3660 Cow Contest

    题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  5. POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包)

    POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包) Description N (1 ≤ N ...

  6. POJ 3660—— Cow Contest——————【Floyd传递闭包】

    Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit  ...

  7. POJ 3660 Cow Contest 传递闭包+Floyd

    原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Subm ...

  8. POJ 3660 Cow Contest(传递闭包floyed算法)

    Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3234 Descr ...

  9. ACM: POJ 3660 Cow Contest - Floyd算法

    链接 Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Descri ...

随机推荐

  1. java程序设计原则

    前言: 前言:java这种面向对象的的语言其实是很符合人的生活思维模式的,因为它以对象作为自己的研究对象,所谓"万物皆对象".一个人.一颗苹果.一只蚂蚁都是对象.所以它的设计原则和 ...

  2. 在 CentOS7.0 上搭建 Chroot 的 Bind DNS 服务器

    BIND(Berkeley internet Name Daemon)也叫做NAMED,是现今互联网上使用最为广泛的DNS 服务器程序.这篇文章将要讲述如何在 chroot 监牢中运行 BIND,这样 ...

  3. POJ 1021 2D-Nim

    Description The 2D-Nim board game is played on a grid, with pieces on the grid points. On each move, ...

  4. 分享:Python中的位运算符

    按位运算符是把数字看作二进制来进行计算的.用的不太多,简单了解. 下表中变量 a 为 60,b 为 13二进制格式如下: a = 0011 1100 b = 0000 1101 a&b = 0 ...

  5. NDK配置debug环境时:Error:FAILURE: Build failed with an exception

    Error:FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:ex ...

  6. Dynamics CRM 2015-Ribbon In Basic Home Tab

    前文中有说到关于Form上Ribbon的配置以及控制,而Ribbon Button还可以在其它地方的配置,今天就来说说在Basic Home Tab里面的配置,效果图如下: 具体配置Customiza ...

  7. 一个简单清晰的Redis操作类

    <?php /** * redis处理的二次封装 * */ class Redis{ private $_redis; private $_config; public function __c ...

  8. PhpStorm如何下载github上的代码到本地

    1.看着菜单栏有一个VCS(Virus Capture Scripter)集群服务器的选项,选择其下面的Checkout from Version Control,然后 (1)选择GIT:输入git的 ...

  9. tcp/ip 卷一 读书笔记(1)tcp/ip 概述

    TCP/IP协议概述 术语 广域网 WAN 局域网 LAN TCP/IP四层网络模型 TCP/IP通常被认为是一个四层协议系统 网络接口层 包括arp,rarp协议,包括操作系统中的网卡驱动程序和对应 ...

  10. 兼容ie7以上的 placeholder属性

    最近项目踩过的坑,不考虑ie的可以拐弯绕路走了. css3的新属性 占位符 placeholder用着多舒服 . 偏偏万恶的ie不支持,网上有几种方法是用焦点事件代替的,不过会失去原有的特性.一旦获取 ...