nyoj 211&&poj 3660】的更多相关文章

Cow Contest 时间限制:1000 ms  |  内存限制:65535 KB 难度:4 描述 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 u…
链接: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<=…
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…
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 POJ - 3660 :http://poj.org/problem?id=3660   参考:https://www.cnblogs.com/kuangbin/p/3140837.html   题意: n头牛,有m对牛进行了比赛,现在告诉你每队牛比赛的结果,A胜B,问有几头牛的排名可以确定. 思路: 题目给出了m对的相对关系,求有多少个排名是确定的. 使用floyed求一下传递闭包.如果这个点和其余的关系都是确定的,那么这个点的排名就是确定的. #include <al…
题目链接: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…
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…
题目链接: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 <…
题目链接:http://poj.org/problem?id=3660 Description N ( ≤ N ≤ ) cows, conveniently numbered ..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 am…
原题链接: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 题目大意: 给出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对关系.(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少头牛的排名. 传递闭包: 关系之间具有传递性(例如a> b, b> c, 那么a> c), 在那些已给出的关系基础上, 通过传递性, 把所有可能的关系都找出来. 思路:假设一头牛可以被X头牛打败,可以打败Y头牛.如果这头牛的排名可以确定则X+Y=N-1.想到Floyd正好可以求X→Y的关系,只是将Floyd求距离改成了判…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=211 思路:我的思路是对每一个点,向上广搜,向下广搜,看总共能不能搜到n-1个结点,能,表明该节点的等级确定.  题目标程给的方法是floyd+统计,似乎简单的多,我弄复杂了,还是贴个代码吧! 代码如下: #include "stdio.h" #include "string.h" #include "queue" using names…
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…
题意难懂是POJ的标配,这都TM赖本泽马. 题意:有N头牛进行了M场比赛,比赛双方是A - B 且总是A赢(前面的那个数赢),如果说A赢B,B赢C 则可以确定A赢C.问最终多少头牛的排名可以确定. 思路:用弗洛伊德判读每两点之间是否有输赢关系(INF表示没关系),如果某个点与所有点都有输赢关系,则这个点的排名可以确定. #include<stdio.h> #include<string.h> #include<cstring> #include<string>…
题目传送门 题意: m组关系,A能打败B,问最后有几头牛的排名能确定 分析:如果排名确定,那么能打败它的到它一定通,它到能打败的一定能通,也就是和为n-1.用Floyd的传递闭包 #include <cstdio> #include <algorithm> #include <cstring> using namespace std; const int N = 1e2 + 5; bool d[N][N]; int in[N]; int n, m; void Floyd…
链接 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…
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=230 题意:给你许许多多的木棍,没条木棍两端有两种颜色,问你在将木棍相连时,接触的端点颜色必须相同,是否能把它们都连起来 思路:很明显的欧拉路径,但题目给的字符串数据很大,得用字典树存取. 代码如下: #include "stdio.h" #include "string.h" #include "stdlib.h" #define N…
233333... Description: 就是说呢.牛是的实力室友大小之分的.然后呢.告诉你很多pair 表示任意两头牛之间的实力大小.按实力排序之后.问你一共有多少只牛的排名是确定了的. T_T == 坑了好多WA....应该是 = 好吧..貌似是拓扑排序的floyd算法..数据太小..三重循环水过.就是判断有多少只牛的入度出度和是n-1就欧克了.... 代码: #include<stdio.h>#include<iostream>#include<string.h&g…
本来想自己写个bfs让他顺着胜负边爬 走到拐弯处就判定无法确定次序 然后我发现有多余的边并不会自己省略掉 要写个O(n^3)的删掉多余边这都不如Floyd了 看奚政学长写的是拓扑序也能解 然后在理解看他的文章的时候智商下线了 Floyd都没认出来 最后自己写了个(标准)Floyd 华丽得wa了 然后查出来是i j k 次序写的不好 嗯原始算法还是要复习一下的 有空去学一下拓扑序解法 以上 #include <cstdio> #include <cstring> int main()…
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 题目链接: 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…
MPI Maelstrom 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/G Description BIT has recently taken delivery of their new supercomputer, a 32 processor Apollo Odyssey distributed shared memory machine with a hierarchical communication subsy…
/* floyd 传递闭包 开始Floyd 之后统计每个点能到的或能到这个点的 也就是他能和几个人确定胜负关系 第一批要有n-1个 然后每次减掉上一批的人数 麻烦的很 复杂度上天了.... 正难则反 我们考虑一定不能确定排名的 */ #include<iostream> #include<cstdio> #include<cstring> #define maxn 110 using namespace std; int n,m,f[maxn][maxn],ans; i…
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)个学生参加编程比赛. 给出m条实力信息.(1<=M<=4500) 其中每一条的格式为 A B (1<=A<=N,1<=B<=N,A!=B) 意思是A的实力比B强. 如果A比B强且B比C强,那么A一定比C强. 问最后有多少名学生可以确定他的排名. 保证输入信息不存在矛盾 题解 n<=100!!! 若A强于B则A向B连一条单向边 直接强行floyed判断连通性,如果这个点能到达的点数和能到达它的点数和为n-1则说明它的排名是…
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…
<题目链接> 题目大意: 有n头牛, 给你m对关系(a, b)表示牛a能打败牛b, 求在给出的这些关系下, 能确定多少牛的排名. 解题分析: 首先,做这道题要明确,什么叫确定牛的排名.假设该牛被x头牛打败(直接或间接),同时它也有y头手下败将(直接或间接),当x+y=n-1时,即除这头牛本身外,其他所有的牛都为这头牛贡献了出度或者入度.即,当这头牛与其它所有的牛的输赢关系都确定时(直接或间接),这头牛的排名也就可以确定了.而题目只给出了一些牛的直接输赢关系,这时,我们就可以利用Floyed算法…
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…
题意:题目给出了m对的相对关系,求有多少个排名是确定的. 链接:点我 如果这个点到其他点的关系是确定的,那么这个点就是确定的,注意如果这个点到不了其他点,但其他点能到这个点,那么这个点和其他点的关系是确定的 样例图:…