H - Cow Contest
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std; const int maxn = ;
const int oo = 0xfffffff; int v[maxn][maxn]; int main()
{
int N, M; while(scanf("%d%d", &N, &M) != EOF)
{
int i, j, k, a, b, ans=; memset(v, , sizeof(v)); for(i=; i<M; i++)
{
scanf("%d%d", &a, &b);
v[a][b] = ;
} for(k=; k<=N; k++)//注意ijk的顺序
for(i=; i<=N; i++)
for(j=; j<=N; j++)
{
if(v[i][k] && v[k][j])
v[i][j] = ;
} for(i=; i<=N; i++)
{
int sum=;
for(j=; j<=N; j++)
sum = sum + v[i][j] + v[j][i];
if(sum == N-)
ans++;
} printf("%d\n", ans);
} return ;
}
H - Cow Contest的更多相关文章
- POJ 3660 Cow Contest
题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Subm ...
- POJ 3660 Cow Contest (floyd求联通关系)
Cow Contest 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/H Description N (1 ≤ N ≤ 100) ...
- POJ 3660 Cow Contest(传递闭包floyed算法)
Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5989 Accepted: 3234 Descr ...
- POJ3660——Cow Contest(Floyd+传递闭包)
Cow Contest DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a prog ...
- Bzoj 1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 传递闭包,bitset
1612: [Usaco2008 Jan]Cow Contest奶牛的比赛 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 891 Solved: 590 ...
- POJ 3660 Cow Contest(Floyd求传递闭包(可达矩阵))
Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 16341 Accepted: 9146 Desc ...
- POJ 3660 Cow Contest (dfs)
Cow Contest Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 11129 Accepted: 6183 Desc ...
- nyoj 211——Cow Contest——————【floyd传递闭包】
Cow Contest 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 N (1 ≤ N ≤ 100) cows, conveniently numbered 1.. ...
- NYOJ 211 Cow Contest (弗洛伊德+传递闭包 )
title: Cow Contest 弗洛伊德+传递闭包 nyoj211 tags: [弗洛伊德,传递闭包] 题目链接 描述 N (1 ≤ N ≤ 100) cows, conveniently nu ...
随机推荐
- SQL SERVER 存储过程基础
一.注释 -- 单行注释,从这到本行结束为注释,类似C++,c#中// /* … */ 多行注释,类似C++,C#中/* … */ 二.变量 (int, smallint, tinyint, deci ...
- iOS 中如何监测某段代码运行的时间
在iOS里面有时间涉及到网络请求,有时间涉及到数据库的查询,我们需要计算该段代码的效率, 以及执行时间方面的问题,为此,可以使用下面方法: double a = CFAbsoluteTimeGetCu ...
- php输出echo、print、print_r、printf、sprintf、var_dump的区别比较
本篇文章是对php输出echo.print.print_r.printf.sprintf.var_dump的区别进行了详细的分析介绍,需要的朋友参考下 用.net开发已经5年了,最近突然想接触 ...
- hdoj 4310 贪心
不知为毛,过不了 我的代码: #include<stdio.h> int main(){ int n,a[30],b[30],temp,i,j,s1,s2; double c[30]; w ...
- 基于jQuery查找dom的多种方式性能问题
这个问题的产生由于我们前端组每个人的编码习惯的差异,最主要的还是因为代码的维护性问题.在此基础上,我对jQuery源码(1.11.3)查找dom节点相关的内容进行了仔细的查阅,虽然并不能理解的很深入 ...
- Bootstrap_表单_表单控件状态
一.焦点状态 焦点状态是通过伪类“:focus”来实现.Bootstrap框架中表单控件的焦点状态删除了outline的默认样式,重新添加阴影效果. <form role="form& ...
- thinkphp 中js 实现刷新
<input name="Button5" value="返回" id="Button5" style="width:56p ...
- 取消开机window 设备选择
问题:开机,出现window 设备选择,在win7 页面上会停留几秒.解决方案:win+R 输入 -msconfig 进入引导 把延迟改为3
- java interface
- Corn Fields
poj3254:http://poj.org/problem?id=3254 题意:给以n*m的方格,方格中有1或者0,在1的地方可以放置一个物品,但是在物品的上下左右不能有不物品,也可以不放,问你最 ...