UVA 1329 - Corporative Network】的更多相关文章

UVa的题目好多,本题是数据结构的运用,就是Union Find并查集的运用.主要使用路径压缩.甚至不须要合并树了,由于没有反复的连线和改动单亲节点的操作. 郁闷的就是不太熟悉这个Oj系统,竟然使用库中的abs就会WA,自己写了个abs小函数就过了. 题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4075 #include <s…
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4075 题意: 有n个结点,開始都是单独的结点,如今有I操作和E操作,I u v表示吧u的父亲结点设为,距离为|u - v| % 1000,E操作询问u到根的距离 代码: #include <stdio.h> #include <iostream> #in…
带权值的并查集的应用: 代码: #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> #define maxn 20005 using namespace std; int f[maxn]; int d[maxn]; int t,n,x,y; ]; int find(int x) { if(f[x]!=x) { int r=find(f[x]); d[x]+=d[f[x]…
题意:一个企业要去收购一些公司把,使的每个企业之间互联,刚开始每个公司互相独立 给出n个公司,两种操作 E I:询问I到I它连接点最后一个公司的距离 I I J:将I公司指向J公司,也就是J公司是I公司的上级,距离为abs(I-J)%1000(貌似G++不支持abs,PE了两发) 思路:转化一下题意就行了,首先刚开始的时候每个公司都是独立的,I操作就是并查集中合并操作,将I这课树并到J这个树上, E操作要求的东西就是 I到I的根节点的距离,先看一个没有路径压缩直接暴力的方法把.(本以为不会过的,…
---恢复内容开始--- Corporative Network Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu [Submit]   [Go Back]   [Status] Description   A very big corporation is developing its corporative network. In the beginning each of the N ente…
UVAlive 3027 Corporative Network 题目:   Corporative Network Time Limit: 3000MS   Memory Limit: 30000K Total Submissions: 3450   Accepted: 1259 Description A very big corporation is developing its corporative network. In the beginning each of the N ent…
A very big corporation is developing its corporative network. In the beginning each of the N enterprises of the corporation, numerated from 1 to N, organized its own computing and telecommunication center. Soon, for amelioration of the services, the…
3027 - Corporative Network A very big corporation is developing its corporative network. In the beginning each of the N enterprisesof the corporation, numerated from 1 to N, organized its own computing and telecommunication center.Soon, for ameliorat…
Corporative Network Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu [Submit]   [Go Back]   [Status] Description   A very big corporation is developing its corporative network. In the beginning each of the N enterprises of th…
                     Corporative Network A very big corporation is developing its corporative network. In the beginning each of the N enterprisesof the corporation, numerated from 1 to N, organized its own computing and telecommunication center.Soon,…