链接:poj 3660 题意:给定n头牛,以及某些牛之间的强弱关系.按强弱排序.求能确定名次的牛的数量 思路:对于某头牛,若比它强和比它弱的牛的数量为 n-1,则他的名次能够确定 #include<stdio.h> #include<limits.h> int a[110][110]; int main() { int n,m,i,j,k,s,sum; while(scanf("%d%d",&n,&m)!=EOF){ for(i=1;i<=…
Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3234 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…
链接 Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu 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. Eac…
解题思路:给出n头牛,和这n头牛之间的m场比赛结果,问最后能知道多少头牛的排名. 首先考虑排名怎么想,如果知道一头牛打败了a头牛,以及b头牛打赢了这头牛,那么当且仅当a+b+1=n时可以知道排名,即为此时该牛排第b+1名. 即推出当一个点的出度和入度的和等于n-1的时候,该点的排名是可以确定的, 即用传递闭包来求两点的连通性,如果d[i][j]==1,那么表示i,j两点相连通,度数都分别加1 Cow Contest Time Limit: 1000MS   Memory Limit: 65536…
/* floyd 传递闭包 开始Floyd 之后统计每个点能到的或能到这个点的 也就是他能和几个人确定胜负关系 第一批要有n-1个 然后每次减掉上一批的人数 麻烦的很 复杂度上天了.... 正难则反 我们考虑一定不能确定排名的 */ #include<iostream> #include<cstdio> #include<cstring> #define maxn 110 using namespace std; int n,m,f[maxn][maxn],ans; i…
题目链接:http://poj.org/problem?id=3660 题意是给你n头牛,给你m条关系,每条关系是a牛比b牛厉害,问可以确定多少头牛的排名. 要是a比b厉害,a到b上就建一条有向边......这样建好之后,如果比a牛厉害的牛都能达到a牛,而a牛能到达比a牛差的牛的话,牛的头数又恰好是n-1头,那么a牛的排名则是确定的. 所以用Flody比较方便,要是i到k能到达,k到j能到达,那么i到j就能到达,i就比j厉害. #include <iostream> #include <…
题意: n个点,m条边. 若A 到 B的边存在,则证明 A 的排名一定在 B 前. 最后求所有点中,排名可以确定的点的个数. n <= 100, m <= 4500 刚开始还在想是不是拓扑排序. n这么小的数据范围,典型的传递闭包.直接可以用Floyd求. 求出传递闭包之后找哪些点与其他所有点都有直接关系,即所有的点和它之间排名都可以确定.计入答案. #include <iostream> #include <cstdlib> #include <cstdio&g…
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…
原题链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8395   Accepted: 4734 Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all kno…
题目链接: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…
题目链接:http://poj.org/problem?id=3660 Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10066   Accepted: 5682 Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all kn…
Cow Contest Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3660 Description N (1 ≤ N ≤ 100) cows, conveniently numbered 1..N, are participating in a programming contest. As we all know, some co…
Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16341   Accepted: 9146 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 other…
Cow Contest POJ - 3660 :http://poj.org/problem?id=3660   参考:https://www.cnblogs.com/kuangbin/p/3140837.html   题意: n头牛,有m对牛进行了比赛,现在告诉你每队牛比赛的结果,A胜B,问有几头牛的排名可以确定. 思路: 题目给出了m对的相对关系,求有多少个排名是确定的. 使用floyed求一下传递闭包.如果这个点和其余的关系都是确定的,那么这个点的排名就是确定的. #include <al…
Cow Contest 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/H 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 certa…
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: 7690   Accepted: 4288 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…
Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5989   Accepted: 3234 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…
Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11129   Accepted: 6183 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 other…
题目链接:https://cn.vjudge.net/problem/POJ-3660 题意 有n头牛,每头牛都有一定的能力值,能力值高的牛一定可以打败能力值低的牛 现给出几头牛的能力值相对高低 问在一场一对一的比赛中,那些牛的排名可以确定下来 思路 一开始还以为是topo排序,每次去掉没有入度或出度的节点 若有两个及以上的节点可以去掉,则排序结束 然后写出来WA两发... 正确思路: 若满足x头牛可以打败牛a,牛a可以打败y头牛,且n==x+y-1时牛a排名唯一确定 那么可以利用Floyd传递…
传送门:http://poj.org/problem?id=3660 题意:有n头牛, 给你m对关系.(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少头牛的排名. 传递闭包: 关系之间具有传递性(例如a> b, b> c, 那么a> c), 在那些已给出的关系基础上, 通过传递性, 把所有可能的关系都找出来. 思路:假设一头牛可以被X头牛打败,可以打败Y头牛.如果这头牛的排名可以确定则X+Y=N-1.想到Floyd正好可以求X→Y的关系,只是将Floyd求距离改成了判…
题意 : 给出 N 头奶牛在比赛的结果,问你最多的能根据给出结果确定其名次的奶牛头数.结果给出的形式为 A  B 代表在比赛当中 A 战胜了 B 分析 : 对于一头奶牛来说,如果我们能确定其他 N - 1 头奶牛和它的关系,那么它的名次就确定了.将奶牛之间的胜负关系建图,如果给出 A B 那么我们建一条 A->B 的边,代表 A 能战胜 B ,当然也表示了 A 和 B 能确立关系,那么现在有一头奶牛 C 且有 C->A 即其与 A 的关系是确定的,那么 B 和 C 的关系是否能确定呢?毋庸置疑…
<题目链接> 题目大意: 有n头牛, 给你m对关系(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少牛的排名. 解题分析: 首先,做这道题要明确,什么叫确定牛的排名.假设该牛被x头牛打败(直接或间接),同时它也有y头手下败将(直接或间接),当x+y=n-1时,即除这头牛本身外,其他所有的牛都为这头牛贡献了出度或者入度.即,当这头牛与其它所有的牛的输赢关系都确定时(直接或间接),这头牛的排名也就可以确定了.而题目只给出了一些牛的直接输赢关系,这时,我们就可以利用Floyed算法…
传送门 解题思路 考试题,想到传递闭包了,写了个O(n^3)的,T了7个点...后来看题解是tm的bitset优化???以前好像没听过诶(我太菜了),其实也不难,时间复杂度O(n^3/32) #include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<bitset> using namespace std; ; inline int rd(){ ,f…
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 contest is conduct…
题目链接: http://poj.org/problem?id=3660 题目大意: 给出n头牛,m个关系,关系为a的战力比b高.求最后可以确定排名的牛的数量 思路: 1.如果一头牛跟其他所有牛都确定了一个输赢关系,那么该牛的排名就得到了确定,所以用floyd跑一遍传递闭包.然后求得每个点的出度(赢了), 入度(输了).若该点的度之和为 n - 1 ,即确定排名. #include<stdio.h> #include<string.h> #define mem(a, b) mems…
http://poj.org/problem?id=3660 题目大意:n头牛两两比赛经过m场比赛后能判断名次的有几头可转 化为路径问题,用Floyd将能够到达的路径标记为1,如果一个点能 够到达剩余你n - 1个点则能判断该点的名次 #include<stdio.h> #include<stdlib.h> #include<math.h> #include<string.h> #include<queue> #define INF 0x3f3f…
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…
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 contest is conduct…
题意:牛之间有绝对的强弱,给出一些胜负关系,问有多少头牛可以确定其绝对排名. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <vector> #include <queue> #include <stack> #include <map> #i…