首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
bro
2026年3月17日 19:25
继续畅通工程 题解:c++
P1311
回复 0
|
赞 0
|
浏览 31
#include <iostream> #include <set> #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <time.h> #include <algorithm> #include <queue> #include <stack> #include <vector> #include <stri...
uly
2026年3月7日 18:15
继续畅通工程 题解:kruskal算法 1时加入并查集0时创建待选节点
P1311
回复 0
|
赞 5
|
浏览 94
#include <bits/stdc++.h> using namespace std; const int Max = 105; int fa[Max]; struct node { int u,v,w; }; int find(int x) { if (fa[x]== x) { return x; } fa[x] = find(fa[x]); return fa[x]; } void myunion(int a ,int b){ fa[find(a)] = fi...
litery
2026年2月22日 15:52
继续畅通工程 题解:Kruskal
P1311
回复 0
|
赞 2
|
浏览 122
#include <bits/stdc++.h> using namespace std; const int maxn=105; struct edge{ int u,v,w; }edges[maxn*maxn]; bool compare(edge a,edge b){ return a.w<b.w; } int fa[maxn]; int find(int x){ if(x==fa[x]) return x; fa[x]=find(fa[x]); return fa[x]; } ...
慎独慎初
2026年2月2日 12:28
继续畅通工程 题解:prim 仅在读入数据时处理
P1311
回复 0
|
赞 2
|
浏览 254
#include<iostream> #include<algorithm> #include<cstring> using namespace std; const int N =101; const int inf=0x3f3f3f3f; int g[N][N]; int cost[N]; bool st[N]; int n; int prim(){ memset(cost,inf,sizeof cost); memset(st,0,sizeof st); ...
武侠剧
2025年8月16日 13:57
继续畅通工程 题解:已经存在的路,成本为0即可
P1311
回复 0
|
赞 0
|
浏览 723
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list> #include <string> #include <cmath> #include <stack> #include <map> #include <sstream> #include <queue> ...
Jayho
2025年5月12日 22:47
继续畅通工程 题解:prim算法
P1311
回复 0
|
赞 5
|
浏览 843
已经连通了的道路把权值设为0,意为不用再对此花费开销,在prim算法的正常处理过程中把这些边加入集合并累加权值时相当于进行一次空操作。 #include<bits/stdc++.h> using namespace std; int prim(vector<vector<int>> graph, int n) { vector<int> dis(n + 1, INT_MAX); vector<bool> visited(n + 1); dis[1] = 0, visited[1] = true; f...
riddle
2025年3月18日 16:27
继续畅通工程 题解:
P1311
回复 0
|
赞 5
|
浏览 1.9k
#include <iostream> #include <algorithm> using namespace std; const int maxn = 105; struct node { int u; // 边的起点 int v; // 边的终点 int w; // 边的权值 int flag; // 1 为已修建,0 为未修建 } edge[maxn * maxn]; int fa[maxn]; // 并查集数组,存储每个节点的父节点 int find(int x) { ...
riddle
2025年3月18日 16:26
继续畅通工程 题解:
P1311
回复 0
|
赞 1
|
浏览 1.6k
#include <iostream> #include <algorithm> using namespace std; const int maxn = 105; struct node { int u; // 边的起点 int v; // 边的终点 int w; // 边的权值 int flag; // 1 为已修建,0 为未修建 } edge[maxn * maxn]; int fa[maxn]; // 并查集数组,存储每个节点的父节点 int find(int x) { ...
RingoCrystal
2025年3月14日 14:26
继续畅通工程 题解:最简单的理解,你看不懂可以过来找我
P1311
回复 0
|
赞 7
|
浏览 1.2k
#include <bits/stdc++.h> using namespace std; struct road{ int a,b,w,s; road(int a,int b,int w,int s):a(a),b(b),w(w),s(s){} bool operator <(road y){ if(s==1)w=0; if(y.s==1)y.w=0; return w<y.w; } }; vector<int>f; int fin...
Lansin
2022年3月26日 18:53
易理解的题解
P1311
回复 1
|
赞 4
|
浏览 6.5k
先把道路修通状态为1的先合并一下。进行判断,如果边数达到N-1,说明道路都通了,则成本为0。如果部分没通,按照修路成本对所有的道路进行sort排序,把状态为0的合并一下,输出成本。 #include<bits/stdc++.h> using namespace std; const int MAX = 105; int N,M; int node[MAX]; int total,sum; struct edge{ int v1,v2; int w; int status; }ed[MAX]; bool operato...
1
2
题目
继续畅通工程
题解数量
20
发布题解
在线答疑
热门题解
1
继续畅通工程 题解:稍微修改1312
2
继续畅通工程 题解:最简单的理解,你看不懂可以过来找我
3
继续畅通工程 题解:kruskal算法 1时加入并查集0时创建待选节点 模板变形
4
继续畅通工程 题解:
5
继续畅通工程 题解:
6
继续畅通工程 题解:prim算法
7
易理解的题解
8
继续畅通工程 题解:求助sos,为何通过率只有80%
9
继续畅通工程 题解:prim 仅在读入数据时处理
10
继续畅通工程 题解:Kruskal