poj 1703 Find them, Catch them
来源:互联网 发布:手机视频录制软件ios 编辑:程序博客网 时间:2024/04/29 02:50
话说要省赛了。。。
刚好最近在看数据结构,打算做一做与看过的有些许关联的题目~
正好看到树了
那就来个并查集吧~
给出n个人,他们只有可能也只属于两个帮派,然后D表示两个人之间是对立的,A表示询问两人是不是在同一帮派。
这个题是一看就知道是并查集,但真正构思的话,还是要考虑一下的。。。
由于人只可能属于两个帮派,所以如果A-B B-C 那么A与C就是同一个帮派的,这个时候我们就可以将A与C并起来了
所以一个emy[ ] 数组记录前一个对立的人,以方便后面来合并。
最后判断两人是否是同一帮派时,要注意可能会不知道当前是否在同一帮派。
另外,输入输出要用scanf 和 prinf 。。。
- POJ 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- POJ-1703 Find them, Catch them
- Poj 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- POJ 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- POJ 1703 - Find them, Catch them
- POJ 1703 Find them, Catch them
- POJ 1703(Find them, Catch them)
- POJ 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- poj 1703 Find them, Catch them
- POJ 1703: Find them, Catch them
- poj 1703 find them,catch them
- POJ--1703--Find them, Catch them
- POJ 1703 Find them, Catch them
- POJ 2449 Remmarguts' Date (SPFA + A星算法) - from lanshui_Yang
- jQuery实现无刷新分页
- MATLAB中实现网页访问功能--urlread()函数
- 学习笔记二:checkbox实现全选功能
- 【c语言】02第一个c语言程序
- poj 1703 Find them, Catch them
- 转载 eoe 大神整理好的 android 开源项目
- thinkphp中的behavior和action
- 1010. 一元多项式求导 (25)
- c语言完数
- CODE 51: Remove Duplicates from Sorted List
- hello world是怎样运行的?
- DEV控件之GridControl导出到Excel ExportToXls
- PHPCMS V9类调用方法