传递闭包(例题POJ3660)】的更多相关文章

概念: 传递一种关系,例如 a//b   b//c  则 a//c 从已知的初始关系中  推出最后所有对象之间的关系 初始时把所有有关系的标记为1 即a[i][j] = 1 然后用Floyd 推出最后的结果  则有关系的两个对象被标记为1 void Floyd() { ; k<=n; ++k) ; i<=n; ++i) ; j<=n; ++j) a[i][j] = a[i][j] || (a[i][k] && a[k][j]); } 例题:POJ3660 题意: n个牛打…
poj3660 题意: 有n头牛, 给你m对关系(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少牛的排名. 分析: 在这呢先说一下关系闭包: 关系闭包有三种: 自反闭包(r), 对称闭包(s), 传递闭包(t). 先画出 R 的关系图,再画出 r(R), s(R), t(R) 的关系图.                        我们今天用的是传递闭包.   仅作为个人理解 传递闭包: 关系之间具有传递性(例如a> b, b> c, 那么a> c), 在那些已给出…
POJ3660 Cow Contest 题目链接:http://poj.org/problem?id=3660 题意:农名约翰有些奶牛,约翰通过让他们决斗来决定他们的排名,约翰让这些奶牛一对一打完一定的局数之后,问有哪些奶牛的排名是可以确定的(注:a打得过b,b打得过c,则a打得c) 根据题意我们明白当一个奶牛和其他的所有奶牛都存在胜负关系的时候,他的排名就是确定的. 思路:利用floyd算法,传递闭包,算出可达矩阵.然后在每一行去查询该点和其他所有的点的联系是不是n-1. 代码: //Auth…
题目链接:https://cn.vjudge.net/problem/POJ-3660 题意 有n头牛,每头牛都有一定的能力值,能力值高的牛一定可以打败能力值低的牛 现给出几头牛的能力值相对高低 问在一场一对一的比赛中,那些牛的排名可以确定下来 思路 一开始还以为是topo排序,每次去掉没有入度或出度的节点 若有两个及以上的节点可以去掉,则排序结束 然后写出来WA两发... 正确思路: 若满足x头牛可以打败牛a,牛a可以打败y头牛,且n==x+y-1时牛a排名唯一确定 那么可以利用Floyd传递…
Cow Contest DescriptionN (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors.…
Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16941   Accepted: 9447 题目链接:http://poj.org/problem?id=3660 Description: N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all k…
题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13085   Accepted: 7289 Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all kn…
Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors. The contes…
  Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 17797   Accepted: 9893 Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than oth…
POJ 3660 Cow Contest / HUST 1037 Cow Contest / HRBUST 1018 Cow Contest(图论,传递闭包) Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some cows code better than others. Each cow has…