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 ...
随机推荐
- I have a dream
1.金斧子 2.有利网 3.金融街
- 【基础练习】【vector】codevs3393 序列倒置
版权信息 转载请注明出处 [ametake版权全部]http://blog.csdn.net/ametake欢迎来看 题目非常easy,本质还是练习一下vector 题目描写叙述 Descriptio ...
- lamp安装指南(转)
主要软件包, 1. httpd-2.2.6.tar.gz 2. mysql-5.0.45-linux-i686-glibc23.tar.gz ( 这个版本是已编译好的压缩包,解压后稍做配置即可使用 ) ...
- [转] 用source命令执行脚本和用sh执行脚本之间的区别
from: http://blog.csdn.net/david_xtd/article/details/8012627 问题: 有很多方式可以执行脚本, 1).source test.bsh 2). ...
- ajax_post方式
test_ajax_post.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" &quo ...
- Interpolator 插值器
简介 Interpolator:撺改者,校对机,分类机,插补器 Interpolator 定义了动画的变化速度,可以实现匀速.正加速.负加速.无规则变加速等,这使得基本的动画得以实现加速.减速等效果. ...
- 大型系统开发sql优化总结(转)
Problem Description: 1.每个表的结构及主键索引情况 2.每个表的count(*)记录是多少 3.对于创建索引的列,索引的类型是什么?count(distinct indexcol ...
- CentOS 6.4搭建zabbix
系统环境:CentOS 6.4 64bit Zabbix版本:zabbix 2.2.3 前提条件:已安装好LNMP环境 一.服务端: 1. 下载zabbix安装包zabbix-2.2.3.tar.g ...
- 商务智能(BI)技术
以下内容仅为兴趣爱好. 商务智能技术是将数据仓库.联机分析处理(OLAP)和数据挖掘等结合起来应用到商业活动中,从不同的数据源收集数据,经过抽取(Extract).转换(Transform)和加载(L ...
- Php GMP
GMP是The GNU MP Bignum Library,是一个开源的数学运算库,它可以用于任意精度的数学运算,包括有符号整数.有理数和浮点数.它本身并没有精度限制,只取决于机器的硬件情况. 本函数 ...