POJ 3660 Cow Contest【floyd】】的更多相关文章

题目链接: 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…
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…
解题思路:给出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…
传送门: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求距离改成了判…
原题链接: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…
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 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…
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…
传送门 解题思路 考试题,想到传递闭包了,写了个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…