链接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1586 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=82831#problem/E In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each o…
题意:在一个叫做QS的星系,他们使用一些特殊的通讯方式,两个人之间通讯需要使用一个网络适配器,但是一个网络适配器只能跟一个人联系,所有它连接几个人就需要及格适配器,而且每个人都有一些不同的偏好,喜欢的适配器的牌子也是不同的,现在让你求出来让QS人之间相互通讯最少需要多少代价? 输入第一行是测试数据组数,下面是一个N,代表N个人,下一样有N个数表示每个人喜欢的适配器的价格,接着一个矩阵,表示两点间通讯(电缆??)的价格. 分析:只要在每条边的权值上加上两个适配器的价格就可以了. *********…
#include<iostream> #include<algorithm> using namespace std; ; struct edge{ int a,b; double w; }e[N]; int p[N]; int a[N]; int n; bool cmp(edge a,edge b) { return a.w<b.w; } int find(int x) { if(p[x]!=x) p[x]=find(p[x]); return p[x]; } int ma…
题目大意: 给出的案例结果得出步骤,如下图所示,从结点1开始查找,找出的一条路径如绿色部分所标注.(关键处在于连接每条路径所需要的适配器的价格得加上去) 代码实现: #include<iostream> #include<cstdio> using namespace std; #define MAX 1000 //注意此处范围得按照题意设置为>=1000,否则会Segmentation Fault #define MAXCOST 0x7fffffff int graph[M…
QS Network Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 1586 Appoint description:  System Crawler  (2015-05-31) Description Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem…
QS Network Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get conne…
ZOJ - 1586 QS Network (Prim) #include<iostream> #include<cstring> using namespace std; +; ;//无穷远 int n; int cost[maxn]; int Edge[maxn][maxn]; int lowcost[maxn]; void Init() { cin>>n; ;i<n;i++) {//读入每个结点的适配器价值 cin>>cost[i]; } ;i&…
题目: In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they need to buy two network adapters (one for each QS) and a segment of network cab…
QS Network 题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1586 Description: In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get conn…
QS Network DescriptionIn the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they need to buy two network adapters (one for each QS) and a segm…
QS Network Time Limit: 2 Seconds      Memory Limit: 65536 KB Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with ea…
Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they…
QS Network Time Limit: 2 Seconds      Memory Limit: 65536 KB Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with ea…
QS Network Time Limit: 2 Seconds      Memory Limit: 65536 KB Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with ea…
E - QS Network 思路:最小生成树,数组不要开小了. #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define MAXN 100010 using namespace std; int t,n,tot,sum,ans; int fa[MAXN],mon[MAXN]; struct nond{ int x,y,z; }v[]; int cmp(…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1586 //zoj 1586 #include<iostream> #include<cstdio> using namespace std; #define N 1005 int a[N][N],low[N],n,ans; int b[N]; int min(int x,int y) { return x<y?x:y; } void prim(int…
POJ 1459 Power Network / HIT 1228 Power Network / UVAlive 2760 Power Network / ZOJ 1734 Power Network / FZU 1161 (网络流,最大流) Description A power network consists of nodes (power stations, consumers and dispatchers) connected by power transport lines. A…
QS Network Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on FZU. Original ID: 1096 64-bit integer IO format: %I64d      Java class name: Main   In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS…
最小生成树,刚刚学了Prim算法. 对每条边变的权值进行预处理,c[i][j] = c[i][j] + p[i] + p[j] 其中c[i][j]为输入的权值,p[i],p[j]为连接这两个节点所需的费用. #include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> using namespace std; ; int c[maxn][maxn];//邻接矩阵 int x…
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=586 题目大意: QS是一种生物,要完成通信,需要设备,每个QS需要的设备的价格不同,并且,这种设备只能在两个QS之间用一次,也就是说,如果一个QS需要和3个QS通信的话,它就必须得买3个设备,同时,对方三个也必须买对应的适合自己的设备.同时,每两个QS之间是有距离的,要完成通信还需要网线,给出每两个QS之间的网线的价值.求一棵生成树,使得所需要的费用最少.数据范围:所有数据都…
题意:若两个QS之间要想连网,除了它们间网线的费用外,两者都要买适配器, 求使所有的QS都能连网的最小费用. 分析:这个除了边的权值外,顶点也有权值,因此要想求最小价值,必须算边及顶点的权值和. 解决方法:用prim算法,在构造邻接矩阵时,在i到j的权值的基础上再加上i点的权值和j点的权值即可. 附上AC代码: #include <stdio.h> #include <string.h> #include <stdlib.h> #define infinity 1000…
zoj1586:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1586 题目大意:最小生成树,不只算两点之间的费用,还要算点的费用,并不是个点只算一次费用,而是每出现一次算一次.题解:其实只需要在算距离时,把两点的距离加入其中在排序就行了. #include<iostream> #include<cstring> #include<algorithm> #include<cstdio>…
Description Several startup companies have decided to build a better Internet, called the "FiberNet". They have already installed many nodes that act as routers all around the world. Unfortunately, they started to quarrel about the connecting li…
A & M - Jungle Roads HDU - 1301 题意:字母之间的路,求最小生成树 题解:处理好建边以后就是一个Prime #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<sstream> #include<cmath> #include<stack> #include<cstd…
Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get connected, they…
题目链接: E - Tunnel Network ZOJ - 3604 题目大意: 给定编号1-n的点,和给定编号1-S 的联通图,刚开始1号联通图只有 1个顶点,就是编号为1的顶点,2号联通图也只有1个顶点,编号为2的顶点,同理 3,4,5知道s: 剩下的顶点还有 s+1,s+2,s+3,….到n: 这些点你可以随机分配,以连边的方式加入到S个联通图里, 现在问...最后由N个点构成的森林..种类,方案数有多少? 凯莱定理讲解:http://www.cnblogs.com/zhj5chengf…
Description Sunny Cup 2003 - Preliminary Round April 20th, 12:00 - 17:00 Problem E: QS Network In the planet w-503 of galaxy cgb, there is a kind of intelligent creature named QS. QScommunicate with each other via networks. If two QS want to get conn…
整套题都没什么难度. POJ 1251 Jungle Roads #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <stack> #include <queue> #include <cctype> #include <cstdio…
学习最小生成树已经有一段时间了 做一些比较简单的题还算得心应手..花了三天的时间做完了kuangbin的专题 写一个题解出来记录一下(虽然几乎都是模板题) 做完的感想:有很多地方都要注意 n == 1 注意double 的精度问题 poj 1251 模板题 大写字母减去'A'+1即是它的编号 #include<stdio.h> #include<string.h> #include<algorithm> #include<map> #include<m…
KUANGBIN带你飞 全专题整理 https://www.cnblogs.com/slzk/articles/7402292.html 专题一 简单搜索 POJ 1321 棋盘问题    //2019.3.18 POJ 2251 Dungeon Master POJ 3278 Catch That Cow  //4.8 POJ 3279 Fliptile POJ 1426 Find The Multiple  //4.8 POJ 3126 Prime Path POJ 3087 Shuffle…