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 ...
随机推荐
- 红米note不好用
手感不错 拍摄效果暗,没有调好 有死机现象
- NSOutputStream\NSInputStream
NSOutputStream-保存网络资源到本地 _filePath = [[NetworkManager sharedInstance] pathForTemporaryFileWithPrefix ...
- C#中问号的使用
1. 可空类型修饰符(?): 引用类型可以使用空引用表示一个不存在的值,而值类型通常不能表示为空. 例如:string str=null; 是正确的,int i=null; 编译器就会报错. 为了使值 ...
- 【C++深入探索】Copy-and-swap idiom详解和实现安全自我赋值
分类: C/C++2012-08-30 21:40 2017人阅读 评论(2) 收藏 举报 任何管理某资源的类比如智能指针需要遵循一个规则(The Rule of Three): 如果你需要显式地声明 ...
- csv操作帮助类
功能描述: 集合转换为csv数据 DataSe转换为csv数据 using System; using System.Collections.Generic; using System.Data; u ...
- Android UI WebView的使用:
Android UI WebView的使用: /** * @author smiling * @date 2016/10 */ 布局: <?xml version="1.0" ...
- Activity启动机制
以下资料摘录整理自老罗的Android之旅博客,是对老罗的博客关于Android底层原理的一个抽象的知识概括总结(如有错误欢迎指出)(侵删):http://blog.csdn.net/luosheng ...
- POJ3750
#include <iostream> #include <stdio.h> #include <cstring> using namespace std; int ...
- 秒味课堂Angular js笔记------过滤器
不同过滤器的小demo. currency number uppercase json limitTo date orderBy filter <script> var filterMy ...
- C++标准库<string>简单总结
C++标准库<string>简单总结 在C++中,如果需要对字符串进行处理,那么它自带的标准库<string>无疑是最好的选择,它实现了很多常用的字符处理函数. 要想使用标准C ...