E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
Religions
POJ 2524 Ubiquitous
Religions
题目链接:http://poj.org/problem?id=2524题意:一所学校每个同学都信仰一种宗教,只能询问两个同学之间的宗教是否相同,求问有多少种不同的宗教#include #include #include usingnamespacestd; #defineN55000 intF[N]; intfind(intx) { if(F[x]!=x) F[x]=find(F[x]); ret
fjy4328286
·
2014-04-22 19:00
POJ 2524 Ubiquitous
Religions
(并查集)
POJ2524UbiquitousReligions(并查集)http://poj.org/problem?id=2524题意: 给你n个节点(节点编号1到n)和m条边,然后问你无向图有多少个连通分量.分析: 初始连通分量有n个。每读入一条边,如果这条边的两个点不在一个连通分量,那么合并两点所属的连通分量。总的连通分量数目就减少1。 输出最终剩余连通分量数目即可。AC代码(新)
u013480600
·
2014-03-12 16:00
ACM
poj2524 Ubiquitous
Religions
照例先上题目8:宗教信仰查看提交统计提问总时间限制: 5000ms 内存限制: 65536kB描述世界上有许多宗教,你感兴趣的是你学校里的同学信仰多少种宗教。你的学校有n名学生(0 usingnamespacestd; #defineMAXN50005 intfa_info[MAXN];//储存结点的父亲在数组中的下标 intsize[MAXN];//每个结点都看成一棵树,那么这棵树有多少个结
mach7
·
2014-03-06 00:00
UNION
find
并查集
Union-Find
poj2524
POJ 2524 Ubiquitous
Religions
(并查集)
DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinterestedinfindingouthowmanydifferentreligionsstudentsinyouruniversitybelievein. Youknowthatthere
gemire
·
2014-03-05 21:00
POJ 2524 Ubiquitous
Religions
(并查集)
链接:http://poj.org/problem?id=2524UbiquitousReligionsTimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 21949 Accepted: 10770DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdiffic
u012823258
·
2014-03-05 16:00
Ubiquitous
Religions
题目描述Therearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinterestedinfindingouthowmanydifferentreligionsstudentsinyouruniversitybelievein. Youknowthattherearenst
u013013910
·
2014-02-21 18:00
编程
算法
C语言
并查集
寒假训练--并查集--Ubiquitous
Religions
UbiquitousReligionsTimeLimit:1000MSMemorylimit:65536K题目描述Therearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinterestedinfindingouthowmanydifferentreligionsstude
u013015642
·
2014-02-20 20:00
(并查集入门)Ubiquitous
Religions
UbiquitousReligionsTimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 21371 Accepted: 10513DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareint
zxdfc
·
2013-12-15 20:00
(使用树结构来支持并查集操作8.4.4)POJ 2524 Ubiquitous
Religions
(并查集的基本操作: 求有多少个相互独立的集合)
/* *POJ_2524.cpp * *Createdon:2013年11月6日 *Author:Administrator */ #include #include usingnamespacestd; constintmaxn=50010; intfather[maxn]; intfind(intx){//并查集的查询 if(father[x]==x){ returnx; } r
caihongshijie6
·
2013-11-06 10:00
poj 2524 - Ubiquitous
Religions
(并查集)
题意:统计1-n的宗教信仰的种类,这里假设:没有关系的两个人的信仰肯定是不同的。思路:并查集来合并所有有相同信仰的人,最后统计集合的个数即可。代码如下:constintM=50005; intp[M],flag[M]; intfind(intx){returnp[x]==x?x:p[x]=find(p[x]);} intmain() { intn,m,a,b,k=0; while(scanf("%
shankeliupo
·
2013-10-22 16:00
Ubiquitous
Religions
(并查集)
Ubiquitous
Religions
Time Limit: 5000MS Memory Limit: 65536K Total Submissions
Simone_chou
·
2013-08-20 23:00
并查集
POJ 2524 Ubiquitous
Religions
Ubiquitous
Religions
Time Limit: 5000MS Memory Limit: 65536K Total Submissions
·
2013-08-14 20:00
poj
UVa:10583 Ubiquitous
Religions
并查集。最后要求输出合并之后集合的个数。 原本我是找到每个结点的祖先并统计个数这样来做的。这里说一种更为高端的做法。 技巧体现在find函数的写法上。将每个集合初始化为-1.表明为根节点,查询时则返回自身。同时压缩路径。最后只统计-1的个数即可。 #include #include #include #include usingnamespacestd; intfather[50005]
kkkwjx
·
2013-08-09 15:00
并查集
poj 2524 Ubiquitous
Religions
/* UbiquitousReligions TimeLimit:5000MSMemoryLimit:65536K TotalSubmissions:20194Accepted:9918 Description Therearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.
locusxt
·
2013-07-25 20:00
poj
cpp
POJ 2524 Ubiquitous
Religions
(并查集)
UbiquitousReligionsTimeLimit: 5000MSMemoryLimit: 65536KDescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinterestedinfindingouthowmanydifferentrelig
synapse7
·
2013-07-25 11:00
数据结构
ACM
并查集
解题报告
POJ 2524 并查集的水题 Ubiquitous
Religions
单纯的并查集的题目所以比较简单需要注意的是由于读入的数据量比较大所以读入用scanf比较好#include #include #definesize_num51000 usingnamespacestd; setsett;//用集合可以方便的知道不同的元素的个数 intp[size_num]; intfindp(intx){returnp[x]==x?x:p[x]=findp(p[x]);} in
u011401504
·
2013-07-22 13:00
ACM
并查集
poj2524
Ubiquitous
Religions
poj 2524 Ubiquitous
Religions
并查集
今天听了东哥的并查集的讲课,回忆起了以往的并查集的知识,自己在好好的写一把,仔细回忆一下自己理解的并查集;并查集进行并和查的操作,对于这到信仰问题,只要知道每个节点的父节点就可以了,不用填加额外的信息。Find(inti){ if(father[i]==i)returni; father[i]=Find(father[i]);//精辟的代码进行了状态压缩只要一次就能把之前的所有节点的父节点都对应好
yangshuolll
·
2013-04-13 00:00
算法
POJ 2524 Ubiquitous
Religions
【并查集入门】
UbiquitousReligionsTimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 19292 Accepted: 9472DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinte
Cfreezhan
·
2013-04-06 22:00
POJ2524:Ubiquitous
Religions
DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinterestedinfindingouthowmanydifferentreligionsstudentsinyouruniversitybelievein.Youknowthattherea
libin56842
·
2013-03-20 21:00
ACM
poj
并查集
POJ 2524 Ubiquitous
Religions
并查集水题,无槽点……#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #includ
speedcell4
·
2013-03-19 07:00
POJUbiquitous
Religions
(非常棒的并查集入门题目)
#include #include usingnamespacestd; intf[50010]; intsum=0; //Accepted360K313MS intfind1(intx){ if(f[x]!=x){ f[x]=find1(f[x]); } returnf[x]; } voidmerge1(inta,intb){ intf1=find1(a); intf2=find1(b); i
wangwenhao00
·
2013-02-22 11:00
BIT1061 Ubiquitous
Religions
题意:学校里的学生有很多信仰,你要知道学校里最多有多少种信仰,但是你不能去问每一个学生,你只能问两个学生他们的信仰是否一样输入有多组样例每组样例的第一行是n和m,n是学生数,从1,到n编号,接下来m行a和b,表示a和b的信仰相同当n和m为0的时候,输入停止解法:并查集#include #include #include usingnamespacestd; intparent[50100]; in
zhangwei1120112119
·
2013-02-04 17:00
【并查集买一送一】Poj 2524——Ubiquitous
Religions
来源:点击打开链接更加标准的模板题,几乎所有OIER和ACMER的培训上都讲过类似的例子,什么配对强盗然后看分几波。。配对敌人看看有几方势力。。配对物品发现有几种。。之类的云云,一概属于并查集。。。再去看看状态压缩。。ORORZ。。我看的课件是OIER的PAS版。。。。。。。。。。高中生IMBA#include #include #include usingnamespacestd; intstu
mig_davidli
·
2013-01-22 16:00
POJ 2524 - Ubiquitous
Religions
AdvancedDataStructures::DisjointSetDescription有n个学生,编号从1~n。学生们大都信仰着各自的神,各自的宗教。当然也有不少同学有着相同的信仰。那么,告诉你哪些同学有相同的信仰,请求出有多少个神在同学们的心中。TypeAdvancedDataStructures:: DisjointSetAnalysis假设一个开头就有n个宗教,然后用并查集并一下,在并
Ra_WinDing
·
2012-10-09 20:00
struct
poj 2524 Ubiquitous
Religions
点击打开链接poj2524思路:简单的并查集分析:输入的时候把相同集合的元素合并在一起,那么我们用一个vis数组来标记集合根节点是否出现过。比如某个几个的根节点为5,那么就把vis[5]=1。这样最后我们只需要枚举一变所有的点,把最后有个根节点求出来就是最大的集合数量代码: #include #include #include #include #include usingnamespacest
cgl1079743846
·
2012-09-24 12:00
poj 2524 Ubiquitous
Religions
(最简单的并查集)
Ubiquitous
Religions
Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 17935
·
2012-09-07 22:00
poj
POJ2524 并查集 Ubiquitous
Religions
并查集:(union-find sets) 一种简单的用途广泛的集合. 并查集是若干个不相交集合,能够实现较快的合并和判断元素所在集合的操作,应用很多,如其求无向图的连通分量个数等。最完美的应用当属:实现Kruskar算法求最小生成树。 http://poj.org/problem?id=2524 import java.util.Scanner; public class
believexkx
·
2012-08-10 08:00
java
算法
并查集
poj 2524 Ubiquitous
Religions
//这题是我接触并查集的第二题,好顺利AC了! //题目给出几个数据对,在同一个数据对中的人的信仰是相同的,需要你求出在给定的人数中,有几种信仰! //将有相同信仰的人组成一颗树,然后统计数的棵树,再加上还有统计的人数,就可以得出了答案! #include"iostream" #include"memory.h" #include"set" usingnamespacestd; constint
yzl_rex
·
2012-04-27 19:00
poj 2524 Ubiquitous
Religions
(并查集)
http://poj.org/problem?id=2524此题求连通分量的数目,之前我也想这么做,可是怎么找呢。。。。好麻烦,后经提醒合并一次减去一个啊,好简单于是就这样水过。还有个地方调了好久,n重复定义,除了主函数地址就变了,还以为编译器坏了--。太大意了。睡觉-,-tomorrowwillbeagoodday.cqlf2524Accepted888K297MSG++969B2012-03-
cqlf__
·
2012-03-21 01:00
Poj 2524 Ubiquitous
Religions
题目大意:输入n和m,n代表一共有n个学生,m代表接下来要输入m行,每行有两个数字表示这两个学生信奉同一个宗教,要求输出这n个人的信教一共有多少种。思路:典型的并查集应用,统计宗教个数的时候借用了STL中的map。#include usingnamespacestd; #include #include #include //Model1 constintMAXSIZE=50010; intran
Detective_Xin
·
2012-01-20 23:00
Ubiquitous
Religions
POJ2524
UbiquitousReligionsTimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 15791 Accepted: 7606DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinte
tiantangrenjian
·
2011-12-19 16:00
c
input
each
idea
POJ-2524 Ubiquitous
Religions
题目链接:http://poj.org/problem?id=2524题目大意:一个学校有N个学生,他们都有1个宗教信仰,现在想知道这N个学生共有多少个不同的宗教信仰。解题思路:很裸的并查集,判断强连通分量的个数,然后用N个宗教信仰减去结点个数(这个宗教全部减去),然后+1(表示他们共同的宗教信仰)。代码如下:#include #include #include #include usingnam
niushuai666
·
2011-11-16 15:00
POJ 2524 Ubiquitous
Religions
并查集
题意:给出一些数对,表示这两个人有相同的宗教信仰,现在要求人们信仰的宗教最多有多少种。题解:并查集。#include #include intfather[50001],r[50001]; intm,n,res; voidmake_set() { for(inti=1;ir[tb]) father[tb]=ta; else father[ta]=tb; if(r[ta]
Tsaid
·
2011-07-24 14:00
POJ2524 Ubiquitous
Religions
并查集
ProblemAddress:http://poj.org/problem?id=2524 简单的并查集。 这个也是我第一次写并查集。刚好想学,又刚好开始切一个师兄的题,刚好切没几道就碰到并查集。便顺手学下来。 这道题是并查集的简单合并。 复杂一点的我也没试过,不知道是不是得生成二叉树之类的来进行优化。 便直接开了一个数组来模拟树。 用father记录根节点,用next记录下一个结点。每读入一个数
Human_CK
·
2011-03-24 19:00
优化
IM
POJ 2524 Ubiquitous
Religions
UbiquitousReligionsTimeLimit: 5000MS MemoryLimit: 65536KTotalSubmissions: 12668 Accepted: 6018DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeeptrackofthemall.Youareinte
hqd_acm
·
2010-09-23 14:00
input
each
idea
Problem--HOJ2033 Ubiquitous
Religions
(Union Set)
Problem--HOJ2033UbiquitousReligions(UnionSet)HOJ2033UbiquitousReligionsAnalysis:ThisisclearlyaproblemwecansolveusingthedatastructurecalledUnionSet.Inthiskindofproblems,weareusuallygivenasetofelementsw
不过一笑
·
2010-08-31 23:00
poj 2524 Ubiquitous
Religions
【并查集】
poj2524UbiquitousReligions【并查集】UbiquitousReligionsTimeLimit:5000MSMemoryLimit:65536KTotalSubmissions:12445Accepted:5900DescriptionTherearesomanydifferentreligionsintheworldtodaythatitisdifficulttokeep
hehexiaobai
·
2010-08-26 19:00
编程语言宗教论
语言的宗教论(转) (2010-02-05 10:16:58) 转载 标签: it 分类:技术杂谈 原文来自If programming languages were
religions
nianshi
·
2010-08-23 14:00
编程
erlang
python
lua
lisp
POJ 2524-Ubiquitous
Religions
并查集
题目来源:http://acm.pku.edu.cn/JudgeOnline/problem?id=2524 解题报告: 简单的并查集的应用吧 方法一: #includeusingnamespacestd;typedefstruct_node{_node*parent;intrank;}node;node**s;voidmakeSet(intx){s[x]=newnode;s[x]->rank=0
kindlucy
·
2010-08-10 20:00
struct
delete
ini
input
each
idea
Learning to Get Out of the Way
In every one of the higher
religions
, there is a strain of infinite optimism on the one
jiangduxi
·
2010-08-10 09:00
eclipse
Go
Social
PKU 2524 Ubiquitous
Religions
PKU2524UbiquitousReligions问题:http://acm.pku.edu.cn/JudgeOnline/problem?id=2524思路:简单并查集,求连通分支的个数,一次AC代码: 1 #include 2 #include 3 #include 4 #define MAX_NUM 50001 5 int father[MAX_NUM]; 6 int rank[MAX_N
A Za, A Za, Fighting...
·
2010-08-09 09:00
pku 2524 Ubiquitous
Religions
pku2524UbiquitousReligions#include using namespace std;const int maxn=50001;int father[maxn];int rank[maxn];void prepare(int n){ for(int i=1;irank[fy]) father[fy]=fx; else if(rank[fx]
Drolca
·
2009-08-20 17:00
PKU Ubiquitous
Religions
(并查集)
http://acm.pku.edu.cn/JudgeOnline/problem?id=2524 题目大意:在大学里假设每个学生都有各自自己不同的信仰,现在题目给你成对出现的数据,标志着这两个人信仰是一样的,现在你要做个调查,调查下学校里到底有多少种不同的宗教信仰。 解题思路:并查集做,因为数据量太大了。 #include#definesize50001intparent[size];intd
q3498233
·
2009-08-14 12:00
pku 2524
pku25242009年7月12日星期日题目链接:PKU 2524 Ubiquitous
Religions
分类:最基本的并查集Code: 1#include 2#define MAXN 50005 3int
蜗牛の狂奔笔记
·
2009-07-12 23:00
如果说编程语言是一种宗教,你的信仰是?(cnBeta)
原文来自If programming languages were
religions
,很有意思,可以从宗教的角度来看看各种常见语言的特点。
alwayswith
·
2009-02-22 09:00
编程
python
erlang
lua
lisp
If Programming Languages Were
Religions
If Programming Languages Were
Religions
… Something for all you programming atheists out there… C would
alwayswith
·
2009-02-22 09:00
python
erlang
C#
lua
lisp
如果说编程语言是一种宗教,你的信仰是?
原文来自If programming languages were
religions
,很有意思,可以从宗教的角度来看看各种常见语言的特点。
love2java
·
2009-01-13 13:00
编程
erlang
python
lua
lisp
我来补充一条,编程语言是一种宗教
先转载,我的补充见最后 原文来自If programming languages were
religions
,很有意思,可以从宗教的角度来看看各种常见语言的特点。
zuroc
·
2009-01-10 08:00
编程
python
erlang
lua
lisp
如果说编程语言是一种宗教,你的信仰是?
原文来自If programming languages were
religions
,很有意思,可以从宗教的角度来看看各种常见语言的特点。
wapysun
·
2009-01-07 19:00
编程
python
erlang
lua
lisp
如果说编程语言是一种宗教,你的信仰是?
原文来自 If programming languages were
religions
C是犹太教——很古老而且戒律很多,但大多数人都熟悉并尊重其戒律。
wutao0603
·
2009-01-07 14:00
编程
C++
c
python
Delphi
上一页
1
2
3
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他