//我看过Discuss说不能用克鲁斯卡尔因为有很多边 //但是只能用G++过,C++的确超时 #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; struct node { int a, b, cost; }c[]; ]; void init(int n) { ; i <= n; i++) fa[i] = i; } bool cmp(node x, no…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9985    Accepted Submission(s): 2843 Problem Description In 2100, since the sea level rise, most of the cities disappear. Thou…
地址:http://acm.hdu.edu.cn/showproblem.php?pid=3371 其实就是最小生成树,但是这其中有值得注意的地方:就是重边.题目没有告诉你两个城市之间只有一条路可走,所以两个城市之间可能有多条路可以走. 举例: 输入可以包含 1 2 3  // 1到2的成本为3   1 2 5  //1到2的成本为5      因此此时应选成本较低的路. 然后,已经连通的城市之间的连通成本为0. 这题用G++提交得到984ms的反馈,用C++提交则得到484ms的反馈. 很想知…
题目:http://acm.hdu.edu.cn/showproblem.php?pid=3371 984ms风险飘过~~~ /************************************************************************/ /* hdu Connect the Cities 最小生成树 题目大意:最小生成树,题目很长,题意很简单就是最小生成树.关键是构建图 */ /****************************************…
这个时间短 700多s #include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; struct node{ int u; int v; int w; }que[100000]; int father[505]; bool cmp(struct node a,struct node b){ return a.w<b.w;…
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=3371 Connect the Cities Description In 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected. The…
Problem Description In 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected. The government wants to build some roads to connect all of these c…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3371 Problem Description In 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connected with others, but most of them become disconnected. The governmen…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 18322 Accepted Submission(s): 4482 Problem DescriptionIn 2100, since the sea level rise, most of the cities disappear. Though some…
Connect the Cities Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 3371 Description In 2100, since the sea level rise, most of the cities disappear. Though some survived cities are still connect…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12903    Accepted Submission(s): 3549 Problem Description In 2100, since the sea level rise, most of the cities disappear. Thou…
Connect the Cities Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 4   Accepted Submission(s) : 3 Problem Description In 2100, since the sea level rise, most of the cities disappear. Though some…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 701 Accepted Submission(s): 212   Problem Description In 2100, since the sea level rise, most of the cities disappear. Though som…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7338    Accepted Submission(s): 2093 Problem Description In 2100, since the sea level rise, most of the cities disappear. Thou…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13299 Accepted Submission(s): 3618 Problem Description In 2100, since the sea level rise, most of the cities disappear. Though so…
Connect the Cities Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 13722    Accepted Submission(s): 3711 Problem Description In 2100, since the sea level rise, most of the cities disappear. Tho…
解题报告:有n个点,然后有m条可以添加的边,然后有一个k输入,表示一开始已经有k个集合的点,每个集合的点表示现在已经是连通的了. 还是用并查集加克鲁斯卡尔.只是在输入已经连通的集合的时候,通过并查集将该集合的点标记到一起,然后剩下的就可以当成是普通的最小生成树来做了题目代码如下: #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #include<cstd…
http://acm.hdu.edu.cn/showproblem.php?pid=3371 AC代码: /** /*@author Victor /* C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string…
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3371 题目不难 稍微注意一下 要把已经建好的城市之间的花费定义为0,在用普通Prim算法就可以了:我没有用克鲁斯卡尔算法(Kruskal's algorithm),因为这题数据比较大,而且要处理大量的数据使它为0,怕超时T^T..... #include<iostream> #include<cstdio> #include<algorithm> using namespa…
Problem Description There are N villages, which are numbered from 1 to N, and you should build some roads such that every two villages can connect to each other. We say two village A and B are connected, if and only if there is a road between A and B…
路飞:" 把原来CSDN的博客转移到博客园咯!" 前段时间,自己负责的任务中刚好涉及到了组织关系的业务需求,自己用了oracle递归查询.下面简单来举个例子.在工作中我们经常会遇到有一定组织关系层次的关系.比如某个省下有多少市,每个市下又有多个区.再或者公司组织部门相互的隶属关系.这时我们就可能会用到 start with connect by prior 递归查询了 用法举例 1. 基本sql语法: select  ...   from  + 表   start with      …
uvaoj 10397 - Connect the Campus Many new buildings are under construction on the campus of the University of Waterloo. The university has hired bricklayers, electricians, plumbers, and a computer programmer. A computer programmer? Yes, you have been…
题目网址:http://acm.hdu.edu.cn/showproblem.php?pid=3371 思路: 这道题很明显是一道最小生成树的题目,有点意思的是,它事先已经让几个点联通了.正是因为它先联通了几个点,所以为了判断连通性 很容易想到用并查集+kruskal. 不过要注意 这题有一个坑点,就是边数很多 上限是25000,排序的话可能就超时了.而点数则比较少 上限是500,所以很多人选择用Prim做.但我个人觉得这样连通性不好判断.其实边数多没关系,我们只要去重就好啦,用邻接矩阵存下两点…
1640 天气晴朗的魔法 题目来源: 原创 基准时间限制:1 秒 空间限制:131072 KB 分值: 20 难度:3级算法题 这样阴沉的天气持续下去,我们不免担心起他的健康. 51nod魔法学校近日开展了主题为"天气晴朗"的魔法交流活动. N名魔法师按阵法站好,之后选取N - 1条魔法链将所有魔法师的魔力连接起来,形成一个魔法阵. 魔法链是做法成功与否的关键.每一条魔法链都有一个魔力值V,魔法最终的效果取决于阵中所有魔法链的魔力值的和. 由于逆天改命的魔法过于暴力,所以我们要求阵中的…
注意输入的数据分别是做什么的就好.还有,以下代码用C++交可以过,而且是500+ms,但是用g++就会TLE,很奇怪. #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <cctype> #include <algorithm> #include <numeric&…
题目描述: 有n个小岛,其中有的小岛之间没有通路,要修这样一条通路需要花费一定的钱,还有一些小岛之间是有通路的.现在想把所有的岛都连通起来,求最少的花费是多少. 输入: 第一行输入T,代表多少组数据. 第二行输入三个整数n , m , k,分别代表一共有n个小岛,m条路径可供选择,k表示有连通岛的个数. 接下来的m行,每行三个整数p , q , c ,代表建设p到q的通路需要花费的钱为c. 接下的k行,每一行的数据输入如下:先输入Q,代表这个连通分量里面有Q个小岛,然后输入Q个小岛,代表这Q个小…
Outlets                                                                                                              Time Limit: 2000/1000 MS (Java/Others)                                                                                               …
一直都不明确sqlnet.ora中的NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)是什么意思.今天看到一篇文档,就是登陆选用的方式.做一个測试: tnsnames.ora  10.10.32.119 =   (DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.32.119)(PORT = 1521))     )     (CONNECT_DAT…
#include<stdio.h> #include<algorithm> #define N (100 + 10) using namespace std; typedef struct {    int x ,y ,c; }NODE; NODE node[N*N]; int  map[N][N]; int  mer[N]; int finds(int x) {    return x == mer[x] ? x : mer[x] = finds(mer[x]); } bool…
转自:http://blog.csdn.net/shahdza/article/details/7779230 [HDU]1213 How Many Tables 基础并查集★1272 小希的迷宫 基础并查集★1325&&poj1308 Is It A Tree? 基础并查集★1856 More is better 基础并查集★1102 Constructing Roads 基础最小生成树★1232 畅通工程 基础并查集★2120 Ice_cream's world I 基础并查集★212…