Cow Contest POJ - 3660
题意
有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的更多相关文章
- Cow Contest POJ - 3660 (floyd 传递闭包)
N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we ...
- Cow Contest POJ - 3660 floyd传递闭包
#include<iostream> #include<cstring> using namespace std; ,INF=0x3f3f3f3f; int f[N][N]; ...
- POJ - 3660 Cow Contest 传递闭包floyed算法
Cow Contest POJ - 3660 :http://poj.org/problem?id=3660 参考:https://www.cnblogs.com/kuangbin/p/31408 ...
- POJ 3660 Cow Contest
题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- 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 ...
- POJ 3660—— Cow Contest——————【Floyd传递闭包】
Cow Contest Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- POJ 3660 Cow Contest 传递闭包+Floyd
原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- POJ 3660 Cow Contest(传递闭包floyed算法)
Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5989 Accepted: 3234 Descr ...
- ACM: POJ 3660 Cow Contest - Floyd算法
链接 Cow Contest Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu Descri ...
随机推荐
- spring boot 使用java9上传到github其他人clone后报错
错误原因: Java.lang.NoClassDefFoundError:javax/xml/bind/JAXBException jdk9存在版本兼容问题. 经过查找资料发现问题所在 大致意思是ja ...
- 【Javascript】在文本框光标处插入文字并定位光标 (转)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- STAThread 和 MTAThread
STAThread:single threaded apartment 直译过来是:单线程单元套间 MTAThread:multiple threaded apartment 直译过来是:多线程单元套 ...
- MYSQL索引的类型和索引的方式
索引的类型: normal:表示普通索引 unique:表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为unique full textl: 表示 全文搜索的索 ...
- zoj 3962 Seven Segment Display 数位dp
非常好的一个题,可以比赛时想到的状态太奇葩,不方便转移,就一直没能AC. 思路:dp(i, j)表示已经考虑了前i位,前i位的和为j的贡献.如果当前的选择一直是最大的选择,那么就必须从0~下一位的最大 ...
- C++中结构体与类的区别(struct与class的区别)
转载来源:http://blog.sina.com.cn/s/blog_48f587a80100k630.html C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据 ...
- php-fpm问题
这个问题怎么说呢?之前遇到这个问题内心是奔溃的.因为我压根不知道是哪里出问题啦.不过,在我努力探索下,最终还是解决了问题. so请记住,坚持不一定成功,但放弃一定失败. 简单描述一下问题: 1.本地的 ...
- 【Unity3D】Unity3D开发《我的世界》之五、创建无限地形(视频)
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/unity_minecraft_05.html 一.导入Unity3D自带的第一人称角色控制器 直接导入就行,我们用 ...
- HI3531uboot开机画面
startvo 0 36 13; startgx 0 0x88000000 1600 0 0 800 600; //startgx 0 0x88000000 2048 0 0 1024 768; se ...
- ClientAbortException: java.net.SocketException: Software caused connection abort: socket write erro
1.错误描述 ClientAbortException: java.net.SocketException: Software caused connection abort: socket writ ...