hdu 4324 Triangle LOVE】的更多相关文章

题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4324 Triangle LOVE Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A don’t love B, then B must love A, vice versa. And there is no pos…
Problem Description Recently, scientists find that there is love between any of two people. For example, between A and B, if A don't love B, then B must love A, vice versa. And there is no possibility that two people love each other, what a crazy wor…
Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1707    Accepted Submission(s): 729 Problem Description Recently, scientists find that there is love between any of two people. For…
Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3603    Accepted Submission(s): 1416 Problem Description Recently, scientists find that there is love between any of two people. Fo…
题目 /***************************参考自****************************/ http://www.cnblogs.com/newpanderking/archive/2012/10/16/2726757.html 上有详细注解,我是看了之后写的,我的代码有一咪咪的改动 //这是一道典型的拓扑排序的题,刚开始时没有理解,//上网查了好多关于拓扑排序的知识才明白,//就是针对一个顶点活动网(Activity On Vertex network),简…
https://vjudge.net/problem/HDU-4324 题意 每组数据一个n表示n个人,接下n*n的矩阵表示这些人之间的关系,输入一定满足若A不喜欢B则B一定喜欢A,且不会出现A和B相互喜欢的情况,问你这些人中是否存在三角恋. 分析 就是求是否存在三元环.判断图是否存在环,可以使用拓扑排序,排序失败则有环.那么如何判断存在的环是三元环呢? 假设现在存在n元环,在环上有这样相邻的三个元素x-->y-->z.如果是z-->x,那么存在三元环:否则,必存在x-->z,那此…
题意:给出n个人,如果a喜欢b,那么b一定不喜欢a,如果b不喜欢a,那么a一定喜欢b 就是这n个点里面的任意两点都存在一条单向的边, 所以如果这n个点不能构成拓扑序列的话,就一定成环了,成环的话就一定能够找到一个三元环 所以只需要判断能不能构成拓扑序列 另外,tle了一晚上是因为用了cin------55555555555555 以后少用cin了----- #include<iostream> #include<cstdio> #include<cstring> #in…
因为题目说了,两个人之间总有一个人喜欢另一个人,而且不会有两个人互相喜欢.所以只要所给的图中有一个环,那么一定存在一个三元环. 所以用拓扑排序判断一下图中是否有环就行了. #include <cstdio> #include <cstring> + ; char G[maxn][maxn]; int c[maxn]; int n; bool dfs(int u) { c[u] = -; ; v < n; v++) ') { ) return false; if(!c[v] &…
Triangle 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Description Mr. Frog has n sticks, whose lengths are 1,2, 3⋯n respectively. Wallice is a bad man, so he does not want Mr. Frog to form a triangle with three of the sticks here. He decides…
Triangle Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0 Problem Description Mr. Frog has n sticks, whose lengths are 1,2, 3⋯n respectively. Wallice is a bad man,…