ural 1106 Two Teams
http://acm.timus.ru/problem.aspx?space=1&num=1106
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; bool g[][];
int vis[];
int main()
{
int n;
scanf("%d",&n);
int a;
memset(g,false,sizeof(g));
for(int i=; i<=n; i++)
{
scanf("%d",&a);
while()
{
if(a==) break;
g[i][a]=true;
g[a][i]=true;
scanf("%d",&a);
}
}
int t=;
memset(vis,,sizeof(vis));
for(int i=; i<=n; i++)
{
if(!vis[i])
{
vis[i]=;
t++;
for(int j=; j<=n; j++)
{
if(g[i][j])
{ vis[j]=;
}
}
}
}
printf("%d\n",t);
int t1=;
for(int i=; i<=n; i++)
{
if(vis[i]==)
{
t1++;
if(t1==t)
printf("%d\n",i);
else printf("%d ",i);
}
}
return ;
}
ural 1106 Two Teams的更多相关文章
- URAL 1106 Two Teams二分图
S - Two Teams Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submi ...
- ural 1106. Two Teams 二分图染色
链接:http://acm.timus.ru/problem.aspx?space=1&num=1106 描述:有n(n<=100)个人,每个人有一个或多个朋友(朋友关系是相互的).将其 ...
- URAL 1106 Two Teams (DFS)
题意 小组里有N个人,每个人都有一个或多个朋友在小组里.将小组分成两个队伍,每个队伍的任意一个成员都有至少一个朋友在另一个队伍. 思路 一开始觉得和前几天做过的一道2-sat(每个队伍任意两个成员都必 ...
- URAL 1208 Legendary Teams Contest(DFS)
Legendary Teams Contest Time limit: 1.0 secondMemory limit: 64 MB Nothing makes as old as years. A l ...
- ural 1106,二分图染色,DFS
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1106 乍一眼看上去,好像二分图匹配,哎,想不出和哪一种匹配类似,到网上查了一下,DFS染 ...
- timus 1106 Two Teams(二部图)
Two Teams Time limit: 1.0 secondMemory limit: 64 MB The group of people consists of N members. Every ...
- 1106. Two Teams(dfs 染色)
1106 结点染色 当前结点染为黑 朋友染为白 依次染下去 这题是为二分图打基础吧 #include <iostream> #include<cstdio> #include ...
- ural 1208 Legendary Teams Contest
题意描述:给定K支队伍,每队三个队员,不同队伍之间队员可能部分重复,输出这些队员同时能够组成多少完整的队伍: DFS,利用DFS深度优先搜索,如果该队所有队员都没有被访问过,那么将该队计入结果,再去选 ...
- ural 1255. Graveyard of the Cosa Nostra
1255. Graveyard of the Cosa Nostra Time limit: 1.0 secondMemory limit: 64 MB There is a custom among ...
随机推荐
- 男装电商Bonobos融资5500万美元,计划IPO,全靠体验店战略 - 国外 - 快鲤鱼
男装电商Bonobos融资5500万美元,计划IPO,全靠体验店战略 - 国外 - 快鲤鱼 男装电商Bonobos融资5500万美元,计划IPO,全靠体验店战略
- Swift基础语法学习总结二
1.函数 1.1 func funcNmae()->(){} 这样就定义了一个函数,它的参数为空,返回值为空,如果有参数和返回值直接写在两个括号里就可以了 1.2 参数需要指明类型,而如果没有返 ...
- 数据库 —— mySQL的基本操作
学习资源: 0.学习教程 :MySQL 教程(runoob.com) (MySQL Tutorial)turtorialPoint 1.学习帮助手册与平台: MySQL学习平台 英文手册chm ...
- sql server 判断相同值的数据
举个栗子, 求出相同作者的书 select * from [books] where author in (select author from [books] group by author ha ...
- 集成对象和 JSON
想象一下,如果 NSDictionary,NSArray,NSString 呾 NSData 都提供方法 相亏转换 JSON 数据,返样丌径好举? 嗯,等等 – 我们正在使用 Objective-C, ...
- linux crontab 定时命令
一直认为Timer是比较好的实现定时器的方法,后来遇到在linux下的命令制定定时任务才发现,Timer的劣势所在,在Timer的时候很可能你的任务会被当做一个死程序被杀掉等等......上次一个同事 ...
- Java基础知识强化30:String类之String的特点(String为什么是final)
1. String字符串特点: 一旦被赋值,字符串值就不能改变. 这里String是final修饰的,具有不可继承性. 2. 为什么String是final? 主要是为了"效率" ...
- JavaScript arguments类数组
1. 什么是类数组 arguments 是一个类数组对象.代表传给一个function的参数列表. 我们来传一个实例. function printArgs() { console.log(argu ...
- JAVA - hashcode与equals作用、关系
Hashcode的作用 总的来说,Java中的集合(Collection)有两类,一类是List,再有一类是Set.前者集合内的元素是有序的,元素可以重复:后者元素无序,但元素不可重复. ...
- 在Blade中结合gperftools检查内存泄露
Blade是我们开发的大规模C++项目构建工具. gperftools是google开发的性能工具,由高效内存分配器,CPU性能分析器,堆分析器,堆检查器等工具组成. 和其他构建工具不同,结合gtes ...