POJ 2524 :Ubiquitous Religions】的更多相关文章

id=2524">Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23171 Accepted: 11406 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested…
Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 32364 Accepted: 15685 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different…
Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know that there are n stud…
题目地址: http://poj.org/problem?id=2524 题目内容: Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 26119   Accepted: 12859 Description There are so many different religions in the world today that it is difficult to keep tra…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23997   Accepted: 11807 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 20668   Accepted: 10153 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 26678   Accepted: 13127 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 30666   Accepted: 14860 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23093   Accepted: 11379 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions   Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 22389   Accepted: 11031 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in fin…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 34122   Accepted: 16477 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23168   Accepted: 11404 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 23090   Accepted: 11378 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in findi…
题目链接: http://poj.org/problem?id=2524 Ubiquitous Religions Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 39369   Accepted: 18782 Description There are so many different religions in the world today that it is difficult to keep track of…
Ubiquitous Religions Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university believe in. You know…
Ubiquitous Religions Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 23580 Accepted: 11609 Description There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding o…
http://poj.org/problem?id=3321 http://acm.hdu.edu.cn/showproblem.php?pid=3887 POJ 3321: 题意:给出一棵根节点为1的边不一定的树,然后给出问题:询问区间和 或者 节点值更新. HDU 3887: 题意:和POJ 3321的题意差不多,只不过对每个节点询问不包含该节点的区间和 思路:今天才学了下才知道有DFS序这种东西,加上树状数组处理一下区间和 和 节点更新. DFS序大概就是我们在DFS遍历一棵树的时候,在进…
POJ 3252:Round Numbers Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10099 Accepted: 3669 Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Sciss…
题目:http://poj.org/problem?id=2524 题意:问一个大学里学生的宗教,通过问一个学生可以知道另一个学生是不是跟他信仰同样的宗教.问学校里最多可能有多少个宗教. 也就是给定一个图的点数和相应的边,问有多少个连通分量. #include<stdio.h> #include<iostream> #include<string.h> using namespace std; ]; int find(int a) { if(bin[a]!=a) ret…
//#include<bits/stdc++.h> #include<iostream> #include<stdio.h> #define max1 50005 using namespace std; int pa[max1],vis[max1]; int find(int a) { while(a!=pa[a]) { pa[a]=pa[pa[a]]; a=pa[a]; } return a; } void build(int a,int b) { int fa=f…
题意:有编号为1到n的学生,然后有m组调查,每组调查中有a和b,表示该两个学生有同样的宗教信仰,问最多有多少种不同的宗教信仰 简单并查集 //#define LOCAL #include <iostream> #include <cstdio> #include <cstring> using namespace std; + ; int parent[maxn], n, m; int GetParent(int x) { return parent[x] == x ?…
Description 当今世界有很多不同的宗教,很难通晓他们.你有兴趣找出在你的大学里有多少种不同的宗教信仰.你知道在你的大学里有n个学生(0 < n <= 50000).你无法询问每个学生的宗教信仰.此外,许多学生不想说出他们的信仰.避免这些问题的一个方法是问m(0 <= m <= n(n - 1)/ 2)对学生, 问他们是否信仰相同的宗教( 例如他们可能知道他们两个是否去了相同的教堂) .在这个数据中,你可能不知道每个人信仰的宗教,但你可以知道校园里最多可能有多少个不同的宗教…
解题思路:输入总人数 n,和m组数据:即和杭电畅通工程相类似,对这m组数据做合并操作后,求最后一共有多少块区域. #include<stdio.h> int pre[50001]; int find(int root) { if(root!=pre[root]) pre[root]=find(pre[root]); return pre[root]; } void unionroot(int x,int y) { int root1,root2; root1=find(x); root2=fi…
对与知道并查集的人来说这题太水了,裸的并查集,如果你要给别人讲述并查集可以使用这个题当做例题,代码中我使用了路径压缩,还是有一定优化作用的. #include <stdio.h> #include <string.h> const int maxn = 500005; int n, m; int pa[maxn]; void init() { for (int i = 1; i <= n; i++) { pa[i] = i; } } int find(int x) { if…
Description 当今世界有很多不同的宗教,很难通晓他们.你有兴趣找出在你的大学里有多少种不同的宗教信仰. 你知道在你的大学里有n个学生(0 < n <= 50000) .你无法询问每个学生的宗教信仰.此外,许多学生不想说出他们的信仰.避免这些问题的一个方法是问m(0 <= m <= n(n - 1)/ 2)对学生, 问他们是否信仰相同的宗教( 例如他们可能知道他们两个是否去了相同的教堂) .在这个数据中,你可能不知道每个人信仰的宗教,但你可以知道校园里最多可能有多少个不同的…
http://poj.org/problem?id=2524 题意:在一所学校里面的人,都有宗教信仰,不过他们的宗教信仰有可能相同有可能不同,但你又不能直接去问他们,但你可以问他们和谁是同一个宗教.通过n次询问,求这个学校最多有多少种宗教信仰. 思路:一个并查集的水题.首先假设这个学校的人全都是不同的信仰.然后再去询问,如果两个人的信仰是相同的,合并这两个人且ans--.最后减出来的ans就是答案. #include <stdio.h> #include <iostream> #i…
http://poj.org/problem?id=1459 题意:有np个发电站,nc个消费者,m条边,边有容量限制,发电站有产能上限,消费者有需求上限问最大流量. 思路:S和发电站相连,边权是产能上限,消费者和T相连,边权是需求上限,边的话就按题意加就好了.难点更觉得在于输入..加个空格..边数组要*2,因为有反向边. #include <cstdio> #include <algorithm> #include <iostream> #include <cs…
http://poj.org/problem?id=3436 题意:题意很难懂.给出P N.接下来N行代表N个机器,每一行有2*P+1个数字 第一个数代表容量,第2~P+1个数代表输入,第P+2到2*P+1是代表输出 输入有三种情况,0,1,2.输出有0,1两种情况输入0代表不能有这个接口,1代表必须要有这个接口,2代表这个接口可有可无.输出0代表有这个接口,1代表没有这个接口.大概输出就是像插头,输入像插座,只有接口吻合才可以相连. 思路:比较简单的最大流,主要是理解题意很难,把每台机器拆成输…
http://poj.org/problem?id=2195 题意:有一个地图里面有N个人和N个家,每走一格的花费是1,问让这N个人分别到这N个家的最小花费是多少. 思路:通过这个题目学了最小费用最大流.最小费用最大流是保证在流量最大的情况下,使得费用最小. 建图是把S->人->家->T这些边弄上形成一个网络,边的容量是1(因为一个人只能和一个家匹配),边的费用是曼哈顿距离,反向边的费用是-cost. 算法的思想大概是通过SPFA找增广路径,并且找的时候费用是可以松弛的.当找到这样一条增…
http://poj.org/problem?id=3281 题意:有n头牛,f种食物,d种饮料,每头牛有fnum种喜欢的食物,dnum种喜欢的饮料,每种食物如果给一头牛吃了,那么另一个牛就不能吃这种食物了,饮料也同理,问最多有多少头牛可以吃到它喜欢的饮料和食物. 思路:一开始还以为二分匹配可以做,当然如果只有食物或者饮料其中一种就可以做.难点在于建图.看了下书,因为要保证经过牛的流量是1(每种食物对应分配给一头牛,每种饮料对应分配给一头牛,避免一头牛吃多份),所以要把牛拆成两个点.形成这样的路…