hdoj 4324 Triangle LOVE 【拓扑】】的更多相关文章

Triangle LOVE Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 3566    Accepted Submission(s): 1395 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): 2586    Accepted Submission(s): 1051 Problem Description Recently, scientists find that there is love between any of two people. Fo…
题目传送门 题意:判三角恋(三元环).如果A喜欢B,那么B一定不喜欢A,任意两人一定有关系连接 分析:正解应该是拓扑排序判环,如果有环,一定是三元环,证明. DFS:从任意一点开始搜索,搜索过的点标记,否则超时.看是否存在两点路程只差等于2,如果存在,则说明有上述的三角环.其他做法. 收获:DFS搜索一定要用vis数组啊,否则很容易超时的 代码(拓扑排序): /************************************************ * Author :Running_T…
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…
题目连接 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…
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…