hdu3038How Many Answers Are Wrong(带权并查集)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038
题解转载自:https://www.cnblogs.com/liyinggang/p/5327055.html
题目大意:有n个数,你不知道具体是啥,只知道有n个,然后输入m组数据,每组包含三个整数,a,b,s,表示区间[a,b]的整数和为s,输出有错误的数据的组数。
解题思路:是个典型的带权并查集,难点就在于更新相对信息值。在查找和合并也要对相对信息值进行更新。
做法是用一个数组存储某个节点到其根节点的距离。把区间的总和看成是两个端点的相对距离。
极力推荐这位大牛的博客:http://blog.csdn.net/niushuai666/article/details/6981689
这题让我学到了很多,特别是关于向量偏移,可以直接找到根节点与子节点的关系
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY0AAAFMCAIAAAC4cXeXAAAPi0lEQVR4nO3d23nyuBqAUQqZy6mCgqiHamiGGqYG5sIJ8UE+G/xJWuv5bwYMsSX5jSHszeUFENvl7B0AmKFTQHQ6BUSnU0B0OgVEp1NAdDoFRKdTQHQ6BUSnU0B0OgVEp1NAdDoFRKdTQHQ6BUSnU0B0OgVEp1NAdDoFRKdTQHQ6BUSnU0B0OgVEp1NAdDoFRKdTQHSZdOpxu1xuj/5N1/szse3zfn3f8bhdEnrPNHiu5/063CbxY+Y3Ag6QR6eGTZqoRK9TSx64tVMJ6XYCO4Tv1CAH1/szdZ3014eFnUpfaiUlm/XV66nE9STUI4tO/Z2hTXcGZ+1PjvrpuT1Ked2nU1QtVKfa106/Z+WwU9fr5HtVz/v1svZ13/rdm7nwetwul+v90Tygs2vjtRy5t/dTf58sNVZQqECdet5vnRO6OSNT11ODh7Zuftyu1+v77J3s1JJXfu0ETCeuc+/PU7e3ftw6N7QOcf7ewfVUeqygUIE61fE+MdPvT/WS8c7R83693Zv3p5736/V+X/a6byRBj9uuTvUrlSjmzzbT975mXvd5UUjpYnWqe4Xz7lTyeqp1bv9u07yDnngfvf/+07N/9ZFMUP/G1a/7uu94DX7Ae6Ppe3//Y/hadzK9UI44nWrOu9/zrX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PoDa5dOq3TD9/99MpqEgOnWp/KuF6f3rdB5XJo1NAzXQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4DodAqITqeA6HQKiE6ngOh0CohOp4Do/gcBSYLaE1UYqwAAAABJRU5ErkJggg==" alt="" width="262" height="220" />
这题我们利用一个sum[]数组保存从某点到其祖先节点距离。
1.从上图我们可以看出,当roota!=rootb时 如果将roota并入rootb,那么是不是 roota->rootb = b->rootb - b->roota
然后我们可以知道 b->roota = a->roota - a->b
所以最后可以推出 roota ->rootb = b->rootb + a->b - a->roota
而roota的根节点是rootb,所以 roota->rootb = sum[roota]
然后依次推出得到 sum[roota] = -sum[a]+sum[b]+v (这里的a要说明一下由于是区间 [a,b] ,[a,b] = [root,b]-[root,a-1],所以a要减一)
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaAAAAFiCAIAAAA/dJuxAAAK9ElEQVR4nO3c0XkbtxaFURaSx1ShPtyC6lE1akY1pAbmQZRMieRwOAQGwMZaHx9uLNshcQ5+0ZZyD0eAUIfWTwCgFoEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCCWwAGxBA6IJXBALIEDYgkcEEvggFgCB8QSOCp5fz0cXt9bPwvmJnBUInC0J3CcvL8eDi9v728vh8Ph8PL28fmjH5//fPI7WDc++vOH//5msDOB4+T99aJh768/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jgglsABsQQOiCVwQCyBA2IJHBBL4IBYAgfEEjgglsABsQQOiCVwQCyBA2IJHBBL4IBYAgfEEjgglsABsQQOiCVwQCyBA2IJHBBL4IBYAgfEEjgglsABsf4HL+C5DbATDiUAAAAASUVORK5CYII=" alt="" width="210" height="178" />
2.如果roota==rootb 是不是 a和b的根节点已经相同了?所以我们只要验证 a->b是否与题中的长度一致了。
所以 a->b = a->root - b->root
然后得到表达式 v = sum[a]-sum[b] (一定要记住这里的sum都是相对于根节点的,sum的更新在路径压缩的时候更新了)
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
const int maxn=;
int par[maxn],rank[maxn],ans; int find(int x)
{
if(par[x]==x)
return x;
int temp=find(par[x]);
rank[x]+=rank[par[x]];
return par[x]=temp;
} void unite(int x,int y,int s)
{
int rootx=find(x);
int rooty=find(y);
if(rootx!=rooty)
{
par[rooty]=rootx;
rank[rooty]=rank[x]+s-rank[y]; //用向量的思维,合并后rooy到rootx的距离就等于x到根距离加上x和y的距离减去y到rooty的距离
}
else
{
if(rank[x]+s!=rank[y])
ans++;
}
} signed main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=EOF)
{
for(int i=;i<=n;i++)
par[i]=i,rank[i]=;
ans=;
while(m--)
{
int a,b,s;
scanf("%d%d%d",&a,&b,&s);
a--;
unite(a,b,s);
}
printf("%d\n",ans);
}
return ;
}
hdu3038How Many Answers Are Wrong(带权并查集)的更多相关文章
- HDU3038 How Many Answers Are Wrong —— 带权并查集
题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3038 How Many Answers Are Wrong Time Limit: 200 ...
- HDU3038 How Many Answers Are Wrong[带权并查集]
How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- 【HDU3038】How Many Answers Are Wrong - 带权并查集
描述 TT and FF are ... friends. Uh... very very good friends -________-b FF is a bad boy, he is always ...
- hdu 3038 How Many Answers Are Wrong ( 带 权 并 查 集 )
How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- How Many Answers Are Wrong(带权并查集)
How Many Answers Are Wrong http://acm.hdu.edu.cn/showproblem.php?pid=3038 Time Limit: 2000/1000 MS ( ...
- HDU3038:How Many Answers Are Wrong(带权并查集)
How Many Answers Are Wrong Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- HDU 3038 How Many Answers Are Wrong(带权并查集)
太坑人了啊,读入数据a,b,s的时候,我刚开始s用的%lld,给我WA. 实在找不到错误啊,后来不知怎么地突然有个想法,改成%I64d,竟然AC了 思路:我建立一个sum数组,设i的父亲为fa,sum ...
- HDU 3038 - How Many Answers Are Wrong - [经典带权并查集]
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3038 Time Limit: 2000/1000 MS (Java/Others) Memory Li ...
- 【带权并查集】【HDU3038】【How Many Answers Are Wrong】d s
这个题看了2天!!!最后看到这篇题解才有所明悟 转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4298091.html ---by 墨染之樱 ...
随机推荐
- Java 异常处理的误区和经验总结
Java 异常处理的误区和经验总结 1 本文着重介绍了 Java 异常选择和使用中的一些误区,希望各位读者能够熟练掌握异常处理的一些注意点和原则,注意总结和归纳.只有处理好了异常,才能提升开发人员 ...
- [转帖]关于CPU Cache -- 程序猿需要知道的那些事
关于CPU Cache -- 程序猿需要知道的那些事 很早之前读过作者的blog 记得作者在facebook 工作.. 还写过mysql相关的内容 大拿 本文将介绍一些作为程序猿或者IT从业者应该知道 ...
- jQuery EasyUI window窗口使用实例
需求:点击[增加]按钮,弹出窗口,并对所有输入项内容进行校验,校验通过就提交给后台的action处理,没有通过校验就弹窗提示. <!DOCTYPE html> <html> ...
- liunx 运维知识一部分
一 克隆虚拟机 大家都需要做的克隆虚拟机,在克隆虚拟机之前,需要把网卡源的UUID和Mac地址全部删除掉.不然相同会冲突使用不了. 删除UUID跟Mac的操作步骤如下: cd /etc/sysc ...
- 30行Python代码实现人脸检测
参考OpenCV自带的例子,30行Python代码实现人脸检测,不得不说,Python这个语言的优势太明显了,几乎把所有复杂的细节都屏蔽了,虽然效率较差,不过在调用OpenCV的模块时,因为模块都是C ...
- curl 命令 从文件读取参数
-d @filename 从文件读入内容-d @- 从stdin读入内容 -x localhost:8888 加上fiddler代理 一个sample curl -K api.conf -d @b ...
- C#后台绑定select
- 使用电脑adb给Essential Phone刷机 —(官方篇)
用ADB给Essential Phone线刷升级 重要:请确保在刷机前已经解锁,关于解锁教程群里有! 准备 原版boot Twrp boot Magisk卡刷包 到官网下载OTA包 准备好Essent ...
- How to install Niresh Mavericks on PC
ed2k://|file|osx-mavericks.dmg|5653921792|f789090803e9b2c8d582813c0d4a33bf|/ diskutil list diskutil ...
- 三星Galaxy S10可望率先应用于1TB的手机内存
导读 三星电子(Samsung Electronics)1月30日宣布,已经开始量产业界首款容量高达1TB的嵌入式通用闪存存储器(embedded Universal Flash Storage,eU ...