POJ 3660 Floyd传递闭包】的更多相关文章

题意:牛有强弱,给出一些牛的强弱的胜负关系,问可以确定几头牛的排名. 思路: Floyd传递闭包 // by SiriusRen #include <bitset> #include <cstdio> using namespace std; #define f(x) for(int x=1;x<=n;x++) bitset<105>map[105]; int n,m,jyx,jyy,ans=0; int main(){ scanf("%d%d"…
#include<iostream> #include<cstring> using namespace std; ,INF=0x3f3f3f3f; int f[N][N]; int main() { int n,m; cin>>n>>m; memset(f,0x3f,sizeof f); int x,y; ;i<m;i++) { cin>>x>>y; //x>y f[x][y]=; //x<y f[y][x]=-;…
题意:Farmer John想按照奶牛产奶的能力给她们排序.现在已知有N头奶牛(1 ≤ N ≤ 1,000).FJ通过比较,已经知道了M(1 ≤ M ≤ 10,000)对相对关系.每一对关系表示为"X Y",意指X的产奶能力强于Y.现在FJ想要知道,他至少还要调查多少对关系才能完成整个排序. 思路: bitset+Floyd传递闭包. // by SiriusRen #include <bitset> #include <cstdio> using namesp…
是一道floyd变形的题目.题目让确定有几个人的位置是确定的,如果一个点有x个点能到达此点,从该点出发能到达y个点,若x+y=n-1,则该点的位置是确定的.用floyd算发出每两个点之间的距离,最后统计时,若dis[a][b]之间无路且dis[b][a]之间无路,则该点位置不能确定.最后用点个数减去不能确定点的个数即可.题目: Cow Contest Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4813   Accep…
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…
链接: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<=…
题意:给出m个关系,问你能确定机头牛的排名 思路:要确定排名那必须要把他和其他n-1头牛比过才行,所以Floyd传递闭包,如果赢的+输的有n-1就能确定排名. 代码: #include<cstdio> #include<set> #include<map> #include<cmath> #include<stack> #include<vector> #include<queue> #include<cstring…
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…
Treasure Exploration Time Limit:6000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2594 Description Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploratio…
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…