Description 给定 \(n\) 个点,每个点有点权,连结两个点花费的代价为两点的点权和.另外有 \(m\) 条特殊边,参数为 \(x,y,z\).意为如果你选择这条边,就可以花费 \(z\) 的代价将点 \(x\) 和点 \(y\) 连结起来,当然你也可以不选择这条边.求使整个图联通的最小代价 Input 第一行是两个整数,分别是点数 \(n\) 和特殊边的数量 \(m\) 下面一行 \(n\) 个数,第 \(i\) 个数代表点 \(i\) 的点权 下面 \(m\) 行,每行三个数 \…
题目大意:给你$n(n\leqslant2\times10^5)$个点和$m(m\leqslant2\times10^5)$条边,第$i$个点点权为$a_i$.连接$u,v$两个点的代价为$a_u+a_v$或者一条连接$u,v$的边的边权.问连通的最小代价 题解:发现若不考虑特殊边,一定是点权最小的点连向其他点.于是建出由点权最小的点连向其他各点的边,边权为两点点权和.与特殊边一起跑最小生成树即可. 卡点:无 C++ Code: #include <algorithm> #include &l…
题目链接 如果没有特殊边的话显然答案就是权值最小的点向其他所有点连边. 所以把特殊边和权值最小的点向其他点连的边丢一起跑最小生成树就行了. #include <cstdio> #include <algorithm> using namespace std; const int MAXN = 200010; typedef long long ll; inline ll read(){ ll s = 0, w = 1; char ch = getchar(); while(ch &…
题意简述 \(n\)( \(1≤n≤2×10^5\) )个点,每个点 \(i\) 有一个点权 \(a_i\) ( \(1≤a_i≤2×10^{12}\) ),将两个点 \(i\),\(j\) 直接相连的花费是两个点的点权和 \(a_i+a_j\),并且对于特别的\(m\)( \(1≤m≤2×10^5\) )条边 \(u_i\) , \(v_i\) 可以通过花费 \(w\) 点费用连接,求使得所有点互相连通的最小费用. 我们可以从数据范围看出需要注意的事项: 分析1.从\(n\)和\(m\)的范围…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 20978   Accepted: 5898 [Description] David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his co…
Desert King Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 25310   Accepted: 7022 Description David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his coun…
题目描述: David the Great has just become the king of a desert country. To win the respect of his people, he decided to build channels all over his country to bring water to every village. Villages which are connected to his capital village will be water…
03-树1. List Leaves (25) Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each input file contains one test case. For each case, the first line gives a positive integer N (<=10) wh…
Pseudoforest Time Limit:5000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Description In graph theory, a pseudoforest is an undirected graph in which every connected component has at most one cycle. The maximal pseudoforests of…
Pseudoforest Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 1705    Accepted Submission(s): 653 Problem Description In graph theory, a pseudoforest is an undirected graph in which every conne…