timus 1106 Two Teams(二部图)】的更多相关文章

Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every member has one or more friends in the group. You are to write program that divides this group into two teams. Every member of each team must have fri…
链接:http://acm.timus.ru/problem.aspx?space=1&num=1106 描述:有n(n<=100)个人,每个人有一个或多个朋友(朋友关系是相互的).将其分成两组,使每一组都有朋友在另一个组. 思路:大意就是求一个子图使其是二分图.直接用dfs染色. 实际上不是二分图,因为本题每个子集里边可以有边相连,只要满足题目给的条件就行了.比二分图简单了一些. //g++ 4.7.2 #include <cstdio> #include <iostre…
http://acm.timus.ru/problem.aspx?space=1&num=1106 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ][]; ]; int main() { int n; scanf("%d",&n); int a; memset(g,false,sizeof(g)); ; i<=n; i…
S - Two Teams Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice URAL 1106 Description The group of people consists of N members. Every member has one or more friends in the group. You are to write pro…
1106 结点染色 当前结点染为黑 朋友染为白  依次染下去 这题是为二分图打基础吧 #include <iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<stdlib.h> #include<vector> using namespace std; vector<]; ],num; void dfs(int u,int c) {…
题意 小组里有N个人,每个人都有一个或多个朋友在小组里.将小组分成两个队伍,每个队伍的任意一个成员都有至少一个朋友在另一个队伍. 思路 一开始觉得和前几天做过的一道2-sat(每个队伍任意两个成员都必须互相认识)相似然后就往那边想了--看了题解才发现这题很简单-- 我们注意到同组里的人是互不影响的,所以一个人如果已经确定在哪组的话是不会对后面进入这个组的人产生影响的. 所以我们按顺序直接搜就可以了,每个人在他朋友里面找一个已经确定组的,然后放到对面组.如果他的所有朋友都没确定,把他随便放一个组就…
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1106 乍一眼看上去,好像二分图匹配,哎,想不出和哪一种匹配类似,到网上查了一下,DFS染色一遍就可以啦. 两种颜色的很好写.直接没有访问的是1,然后扫邻接表,为2,DFS邻接表. #include <bits/stdc++.h> using namespace std; #define maxn 105 vector<int> G[maxn]; int color[max…
Rnadom  Teams 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.actioncid=88890#problem/B 题目: Description n participants of the competition were split into m teams in some manner so that each team has at least one participant. After the competition eac…
http://poj.org/problem?id=1106 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4488   Accepted: 2379 Description In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don…
Legendary Teams Contest Time limit: 1.0 secondMemory limit: 64 MB Nothing makes as old as years. A lot of cool contests are gone, a lot of programmers are not students anymore and are not allowed to take part at the contests. Though their spirit is f…