URAL 1106 Two Teams二分图】的更多相关文章

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…
链接: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…
题意 小组里有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…
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…
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) {…
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…
题意描述:给定K支队伍,每队三个队员,不同队伍之间队员可能部分重复,输出这些队员同时能够组成多少完整的队伍: DFS,利用DFS深度优先搜索,如果该队所有队员都没有被访问过,那么将该队计入结果,再去选择下一队~ #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <stdlib.h> #include <map>…
题目传送门 /* 题意:三种人,statements,testdata,anthing.要求两个人能完成s和t两个工作,且rank相差2 二分图匹配:此题学习建图技巧,两个集和内部一定没有边相连,rank模4小于2和大于等于2的人才能搭配,并且相差正好2, 两个人会的不能一样.以上条件删选出两个集合,不能按照anthing来分. */ #include <cstdio> #include <iostream> #include <algorithm> #include…
Those are not the droids you're looking for 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1997 Description Bar owner: Hey. We don't serve their kind here. Luke: What? Bar owner: Your droids – they'll have to wait outside. We don't want them here…
Description Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every team has at least one member; every person in the team knows every other person in his team; teams are as close in…
Current Time: 2016-03-11 17:45:36 Contest Type: Public Start Time: 2016-03-04 13:00:00 Contest Status: Running End Time: 2016-05-03 13:00:00 Manager: qwerqqq Clone this contest Edit Delete     ID Origin Title 1 / 1 Problem A HDU 1045 Fire Net 1 / 1 P…
1255. Graveyard of the Cosa Nostra Time limit: 1.0 secondMemory limit: 64 MB There is a custom among the Ural Mafiosi — a big Mafioso’s coffin is to be carried by all his subordinates. The length of the coffin (in meters) equals to the number of the…
1252. Sorting the Tombstones Time limit: 1.0 secondMemory limit: 64 MB There is time to throw stones and there is time to sort stones… An old desolate cemetery is a long dismal row of nameless tombstones There are N tombstones of various shapes. The…
1251. Cemetery Manager Time limit: 1.0 secondMemory limit: 64 MB There is a tradition at the USU championships to call the most hard-to-solve problems coffins. But to distribute coffins is also a very difficult problem. Consider a cemetery with place…
1250. Sea Burial Time limit: 1.0 secondMemory limit: 64 MB There is Archipelago in the middle of a shoreless ocean. An ancient tribe of cannibals lives there. Shamans of this race have been communicating with gods and admonishing people for ages. The…
1249. Ancient Necropolis Time limit: 5.0 secondMemory limit: 4 MB Aerophotography data provide a bitmap picture of a hard-to-reach region. According to the suggestions of scientists, this region is a cemetery of an extinct civilization. Indeed, the p…
Guardian of Decency Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVALive 3415 Description   Problem H - Guardian of Decency Time limit: 15 seconds Frank N. Stein is a very conservative high-school teac…
蛋蛋安利的双倍经验题 1143: [CTSC2008]祭祀river Time Limit: 10 Sec Memory Limit: 162 MB Submit: 1901 Solved: 951 [Submit][Status][Discuss] Description 在遥远的东方,有一个神秘的民族,自称Y族.他们世代居住在水面上,奉龙王为神.每逢重大庆典, Y族都会在水面上举办盛大的祭祀活动.我们可以把Y族居住地水系看成一个由岔口和河道组成的网络.每条河道连接着两个岔口,并且水在河道内按…
Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5244   Accepted: 2192 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that…
2025. Line Fighting Time limit: 1.0 second Memory limit: 64 MB Boxing, karate, sambo- The audience is sick of classic combat sports. That is why a popular sports channel launches a new competition format based on the traditional Russian entertainment…
Problem UVA1627-Team them up! Total Submissions:1228  Solved:139 Time Limit: 3000 mSec Problem Description Your task is to divide a number of persons into two teams, in such a way, that: • everyone belongs to one of the teams; • every team has at lea…
二分图主要是 1.如何建图,谁匹配谁,怎么匹配 2.判断求的是什么:最大匹配=最小点覆盖,最大独立子集=最小路径覆盖=最小边覆盖=图中顶点数-最大匹配 A.2733:棋盘游戏 描述 小希和Gardon在玩一个游戏:对一个N*M的棋盘,在格子里放尽量多的一些国际象棋里面的“车”,并且使得他们不能互相攻击,这当然很简单,但是Gardon限制了只有某些格子才可以放,小希还是很轻松的解决了这个问题(见下图)注意不能放车的地方不影响车的互相攻击. 所以现在Gardon想让小希来解决一个更难的问题,在保证尽…
1837. Isenbaev's Number Time limit: 0.5 second Memory limit: 64 MB Vladislav Isenbaev is a two-time champion of Ural, vice champion of TopCoder Open 2009, and absolute champion of ACM ICPC 2009. In the time you will spend reading this problem stateme…
题目链接: http://poj.org/problem?id=1112 Team Them Up! Time Limit: 1000MSMemory Limit: 10000K 问题描述 Your task is to divide a number of persons into two teams, in such a way, that: everyone belongs to one of the teams; every team has at least one member; e…
唔 神题一道 大家感受一下 1873. GOV Chronicles Time limit: 0.5 secondMemory limit: 64 MB A chilly autumn night. Well wrapped up in a coat, a man is rapidly walking along a gray street. This is the Tradition Keeper of the ACM club in Ural State University. Drizzl…
二分匹配:二分图的一些性质 二分图又称作二部图,是图论中的一种特殊模型. 设G=(V,E)是一个无向图,如果顶点V可分割为两个互不相交的子集(A,B),并且图中的每条边(i,j)所关联的两个顶点i和j分别属于这两个不同的顶点集(i in A,j in B),则称图G为一个二分图. 1.一个二分图中的最大匹配数等于这个图中的最小点覆盖数 König定理是一个二分图中很重要的定理,它的意思是,一个二分图中的最大匹配数等于这个图中的最小点覆盖数.如果你还不知道什么是最小点覆盖,我也在这里说一下:假如选…
Guardian of Decency Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 6133   Accepted: 2555 Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that…
uva 12083 Guardian of Decency Description Frank N. Stein is a very conservative high-school teacher. He wants to take some of his students on an excursion, but he is afraid that some of them might become couples. While you can never exclude this poss…