Electrification Plan Time limit: 0.5 secondMemory limit: 64 MB Some country has n cities. The government has decided to electrify all these cities. At first, power stations in k different cities were built. The other cities should be connected with t…
http://acm.timus.ru/problem.aspx?space=1&num=1982 1982. Electrification Plan Time limit: 0.5 secondMemory limit: 64 MB Some country has n cities. The government has decided to electrify all these cities. At first, power stations in k different cities…
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1982 题意:无向图,给n个点,n^2条边,每条边有个一权值,其中有k个点有发电站,给出这k个点的编号,选择最小权值的边,求使得剩下的点都能接收到电. 发电站之间显然不能有边,那么把k个点合成一个点,然后在图上就MST就可以了. //STATUS:C++_AC_31MS_401KB #include <functional> #include <algorithm> #in…
http://acm.sdut.edu.cn:8080/vjudge/contest/view.action?cid=50#problem/D 最小生成树模板,注意的是这里有k个发电站,它们不再需要连接其他的发电站,所以任何两个发电站之间的权值是0: #include<stdio.h> #include<string.h> ; const int INF = 0x3f3f3f3f; int map[maxn][maxn],power[maxn]; int n,k; void pri…
题目 题意: 无向图,给n个城市,n*n条边,每条边都有一个权值 代表修路的代价,其中有k个点有发电站,给出这k个点的编号,要每一个城市都连到发电站,问最小的修路代价. 思路: prim:把发电站之间e[i][j]都设置为0,然后模板套进去就行. krusl:把所有的发电站都先弄进一个并查集(做法比较机智,先拿其中一个发电站,把剩下的发电站分别与这个发电站找父节点,分别弄进并查集就行). 然后按权值从小到大 排序,不是同一个并查集的就sum+=,再弄进并查集. 复杂度O(n*n) #includ…
Electrification Plan 时间限制: 1 Sec  内存限制: 128 MB提交: 31  解决: 13[提交][状态][讨论版] 题目描述 Some country has n cities. The government has decided to electrify all these cities. At first, power stations in k different cities were built. The other cities should be…
Electrification Plan 题意:在一个无向图中,给你几个源点,找出把所有点连接到源点后最小的消费: 可以利用并查集: 先用结构体把每个边存起来,再按照消费大小排序.之后从消费小的到大的一个个尝试,两个点需要连接的话,连接上同时把消费也算上去: #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <string>…
Description Zaphod Beeblebrox - President of the Imperial Galactic Government. And by chance he is an owner of enterprises that trade in secondhand pens. This is a complicated highly protable and highly competitive business. If you want to stay a lea…
Electrification Plan Prim #include<iostream> #include<cstring> using namespace std; const int INF = 0x3f3f3f3f; ; int n, k; int dis[N], ct[N][N], vis[N]; int Prim() { ; memset(vis, , sizeof(vis)); /* for(int i = 1; i <= n; i++) dis[i] = ct[…
Network Time limit: 1.0 secondMemory limit: 64 MB Andrew is working as system administrator and is planning to establish a new network in his company. There will be N hubs in the company, they can be connected to each other using cables. Since each w…
Non-Yekaterinburg Subway Time limit: 1.0 secondMemory limit: 64 MB A little town started to construct a subway. The peculiarity of the town is that it is located on small islands, some of them are connected with tunnels or bridges. The mayor is sure…
URAL 1994 The Emperor's plan 求组合数 大数用log #include<functional> #include<algorithm> #include<iostream> #include<cstring> #include<cstdio> #include<vector> #include<cmath> #include<string> #include<queue>…
题意  一个城市原来有l个村庄 e1条道路  又添加了n个村庄 e2条道路  后来后销毁了m个村庄  与m相连的道路也销毁了  求使全部未销毁村庄相互连通最小花费  不能连通输出what a pity! 还是非常裸的最小生成树  把销毁掉的标记下  然后prim咯  结果是无穷大就是不能连通的 #include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int N =…
题意:求一幅无向图的最小生成树与最小生成树,不存在输出-1 解法:用Kruskal求最小生成树,标记用过的边.求次小生成树时,依次枚举用过的边,将其去除后再求最小生成树,得出所有情况下的最小的生成树就是次小的生成树.可以证明:最小生成树与次小生成树之间仅有一条边不同.不过这样复杂度有点高,可达O(m^2). 求次小生成树有O(mlogm+n^2)的算法,详见 代码: #include <iostream> #include <cstdio> #include <cstring…
期望$dp$. $dp[i][j]$表示第$1$种人有$i$个,第$2$种人有$j$个的情况下,到达目标状态的期望值.初始化$dp[i][0]=i$. 枚举一下这个状态死多少人,取个$max$,最后$dp[n-k][k]$就是答案. #include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include&…
2062. Ambitious Experiment Time limit: 3.0 secondMemory limit: 128 MB During several decades, scientists from planet Nibiru are working to create an engine that would allow spacecrafts to fall into hyperspace and move there with superluminal velocity…
1272. Non-Yekaterinburg Subway Time limit: 1.0 secondMemory limit: 64 MB A little town started to construct a subway. The peculiarity of the town is that it is located on small islands, some of them are connected with tunnels or bridges. The mayor is…
Truck History 题目链接: http://acm.hust.edu.cn/vjudge/contest/124434#problem/E Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture, or for bricks. The company has its…
Building a Space Station 题目链接: http://acm.hust.edu.cn/vjudge/contest/124434#problem/C Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a…
题目连接:problemId=542" target="_blank">ZOJ 1542 POJ 1861 Network 网络 Network Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge Andrew is working as system administrator and is planning to establish a new network in his com…
Problem Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task. The space station is made up with a num…
来源:dlut oj 1105: Zhuo’s Dream Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 40 Solved: 14[Submit][Status][Web Board] Description Zhuo is a lovely boy and always make day dream. This afternoon he has a dream that he becomes the king of a kingdom calle…
1814: Ural 1519 Formula 1 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 942  Solved: 356[Submit][Status][Discuss] Description Regardless of the fact, that Vologda could not get rights to hold the Winter Olympic games of 20**, it is well-known, that t…
题目: Description You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task. The space station is made up with a number…
poj:1258 Agri-Net Time Limit: 1000 MS Memory Limit: 10000 KB 64-bit integer IO format: %I64d , %I64u Java class name: Main [Submit] [Status] [Discuss] Description Farmer John has been elected mayor of his town! One of his campaign promises was to bri…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4126 Genghis Khan the Conqueror Time Limit: 10000/5000 MS (Java/Others)Memory Limit: 327680/327680 K (Java/Others) 问题描述 Genghis Khan(成吉思汗)(1162-1227), also known by his birth name Temujin(铁木真) and templ…
id=1789">Truck History Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17610   Accepted: 6786 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, other for furniture,…
http://poj.org/problem?id=1789 Truck History Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 32474   Accepted: 12626 Description Advanced Cargo Movement, Ltd. uses trucks of different types. Some trucks are used for vegetable delivery, o…
You are a member of the space station engineering team, and are assigned a task in the construction process of the station. You are expected to write a computer program to complete the task. The space station is made up with a number of units, called…
Transfer water Time Limit: 5000/3000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 6126    Accepted Submission(s): 2181 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4009 Description: XiaoA lives in a village. Las…