摘要: 链接http://acm.hdu.edu.cn/showproblem.php?pid=4324此题可以一遍拓扑排序判环求解 即只需要找到一个环,就必定存在三元环 证明如下: 假设存在一个n元环,因为a->b有边,b->a必定没边,反之也成立 所以假设有环上三个相邻的点a-> b-> c,那么如果c->a间有边,就已经形成了一个三元环,如果c->a没边,那么a->c肯定有边,这样就形成了一个n-1元环。。。。 所以只需证明n为4时一定有三元环即可,显然成立。View Code 1 #include <stdio.h> 2 #include 阅读全文
posted @ 2012-08-02 09:44 淡墨æ末央 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 链接http://acm.hdu.edu.cn/showproblem.php?pid=4324View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 #include <algorithm> 5 using namespace std; 6 char map[2500][2500]; 7 int in[2500]; 8 int main( ) 9 {10 int T;11 scanf("%d", &T );12 for( 阅读全文
posted @ 2012-08-02 09:41 淡墨æ末央 阅读(106) 评论(0) 推荐(0) 编辑