摘要: 题意:给的就是n个虫子 m对虫子发生过关系 然后问有没有虫子是同性恋。分析:题目等价为,n个点,m条边,能否仅用两种颜色染完所有点,并使每条边的两个点不同色。bfs,遍历每个顶点,如果相邻顶点染有相同的颜色,说明有同性恋!代码:View Code 1 #include <iostream> 2 #include <stdio.h> 3 #include <memory.h> 4 #include <queue> 5 using namespace std; 6 const int maxnum=2001; 7 bool array[maxnum] 阅读全文
posted @ 2012-08-12 12:35 pushing my way 阅读(299) 评论(0) 推荐(0) 编辑