这题比较简单,注意路径压缩即可. AC代码 //#define LOCAL #include <stdio.h> #include <algorithm> using namespace std; const int maxn = 20000+5; int par[maxn], dis[maxn]; void init(int n) { for(int i = 0; i <= n; i++) { par[i] = i; dis[i] = 0; } } int findRoot…
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…
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…
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…
                     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,…
Corporative Network Problem's Link Mean: 有n个结点,一开始所有结点都是相互独立的,有两种操作: I u v:把v设为u的父节点,edge(u,v)的距离为abs(u-v)%1000; E u:输出u到根节点的距离. analyse: 经典的并查集习题!Rujia挑选的题目真心不错. 做法很巧妙,但是要对并查集和路径压缩有深入的了解才能想到这种做法. 由于每次E操作都会加入一个新的结点,而且每次都是把一个结点指向另一个结点,所以说不会同时存在两个或两个以上…
题意: 有 n 个节点,初始时每个节点的父节点都不存在,你的任务是执行一次 I 操作 和 E 操作,含义如下: I  u  v   :  把节点 u  的父节点设为 v  ,距离为| u - v | 除以 1000 的余数. E u   : 询问u 到根节点的距离. 解题思路: 因为题目只查询节点到根节点的距离,所以每棵树处理根节点不能换之外.其他节点的位置可以随意改变,这恰好符合并查集的特点,但是附加了一点东西....在两点之间有了一个附加的权值(距离)..所以就是加权并查集了..题目给的是节…
---恢复内容开始--- 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…
3027 - Corporative Network 思路:并查集: cost记录当前点到根节点的距离,每次合并时路径压缩将cost更新. 1 #include<stdio.h> 2 #include<algorithm> 3 #include<iostream> 4 #include<string.h> 5 #include<math.h> 6 #include<stack> 7 #include<set> 8 #inc…
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…