HDU3047 Zjnu Stadium 带权并查集】的更多相关文章

转:http://blog.csdn.net/shuangde800/article/details/7983965 #include <cstdio> #include <cstring> #include <queue> #include <set> #include <map> #include <stack> #include <cstdlib> #include <algorithm> #includ…
Zjnu Stadium Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3179 Accepted Submission(s): 1224 Problem Description In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zh…
题目大意: 有n个人坐在zjnu体育馆里面,然后给出m个他们之间的距离, A B X, 代表B的座位比A多X. 然后求出这m个关系之间有多少个错误,所谓错误就是当前这个关系与之前的有冲突. 分析: 首先我们假设所有节点均在不同行的0位置,即rank[]初始化需为零,同时p[]需要初始化为-1,表示各个节点之间不存在联系,相互独立: 接下来,我们获取信息:A B X:那么我们需要检查 : 1. 如果A B的father相同,那么说明前面的一组(A B X)直接或者间接地更新了A B间的距离,我们便…
题意:有一个环形体育场,有n个人坐,给出m个位置关系,A B x表示B所在的列在A的顺时针方向的第x个,在哪一行无所谓,因为假设行有无穷个. 给出的座位安排中可能有与前面矛盾的,求有矛盾冲突的个数. #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; ; int n,m,r; int father[maxn];…
HDU3047 Zjnu Stadium Problem Description In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of people. The audience Seats made a circle. The to…
题意:一个300列的无限行的循环场地,a b d代表a,b顺时针相距d的距离,现在给你一些距离,判断是否有冲突,如果有冲突计算冲突的次数 思路:带权并查集 a,b的距离等于b到根节点的距离 - a到根节点的距离 1.当a,b在同一集合的时候就用b到根节点的距离 - a到根节点的距离和当前输入的距离进行对比,看是否满足条件 2.当a,b不在同一集合的时候合并两个节点,更新距离 向量法,方向一定要搞清楚,父亲指向儿子 如果x的父亲rootx ,y的父亲是rooty rootx --> x, root…
http://acm.hdu.edu.cn/showproblem.php?pid=3047 题意: 给出n个座位,有m次询问,每次a,b,d表示b要在a右边d个位置处,问有几个询问是错误的. 思路: 基础带权并查集. #include<iostream> #include<cstdio> using namespace std; +; int n,m; int p[maxn],r[maxn]; int finds(int x) { if(p[x]==x) return x; in…
http://acm.hdu.edu.cn/showproblem.php?pid=3047 [题意] http://blog.csdn.net/hj1107402232/article/details/9921311 [Accepted] #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<cmath> #include<algor…
题意:浙江省第十二届大学生运动会在浙江师范大学举行,为此在浙师大建造了一座能容纳近万人的新体育场. 观众席每一行构成一个圆形,每个圆形由300个座位组成,对300个座位按照顺时针编号1到300,且可以认为有无数多行.现在比赛的组织者希望观众进入场地的顺序可以更加的有趣,在门票上并没有规定每个人的座位,而是与这个圈中某个人的相对位置,可以坐在任意一行. 门票上标示的形式如下:A B x 表示第B个人必须在A的顺时针方向x个位置(比如A坐在4号位子,x=2,则B必须坐在6号位子). 现在你就座位志愿…
Zjnu Stadium 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=3047 Problem Description In 12th Zhejiang College Students Games 2007, there was a new stadium built in Zhejiang Normal University. It was a modern stadium which could hold thousands of peop…