首页
DreamJudge
院校信息
专业题库
模拟考试
机试真题
上岸课程
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
riddle
2025年3月18日 16:27
继续畅通工程 题解:
P1311
回复 0
|
赞 1
|
浏览 145
#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
|
浏览 157
#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
|
赞 3
|
浏览 145
#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
|
浏览 5.7k
先把道路修通状态为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...
zxjrheaven
2025年3月5日 11:57
继续畅通工程 题解:爆改原畅通工程
P1311
回复 0
|
赞 0
|
浏览 162
#include <bits/stdc++.h> using namespace std; const int maxn=105; struct node { int u,v,w,a; }edge[maxn*maxn]; int cmp(node A,node B) { return A.w<B.w; } int fa[maxn]; int find(int x) { if(x==fa[x])return x; &n...
zcq107
2025年1月19日 13:57
继续畅通工程 题解:求助sos,为何通过率只有80%
P1311
回复 1
|
赞 2
|
浏览 401
使用克鲁斯卡尔算法,输入过程中,当s==1时,直接合并,使用sort按权值从小到大排序,然后依次取出权值最小且没有修建的边,权值累加,有什么问题,求解答? #include<bits/stdc++.h> using namespace std; const int N = 105; int p[N]; struct EDGE{ int a,b,w,s; }edge[N*N]; bool cmp(EDGE e1,EDGE e2){ return e1.w<e2.w; } int find(int x){ ...
阿离
2024年3月18日 18:06
继续畅通工程 题解:稍微修改1312
P1311
回复 0
|
赞 9
|
浏览 843
#include <bits/stdc++.h> using namespace std; const int maxn=105; int fa[maxn]; struct node{ int u,v,w,m; }edge[maxn*maxn]; int cmp(node a,node b){ if(a.m!=b.m) return a.m>b.m; else return a.w<b.w; } int find(int x){ if(x==fa[x]) return x; fa[x]=find(fa[x])...
JOURISON
2024年3月18日 10:40
继续畅通工程 题解:
P1311
回复 0
|
赞 3
|
浏览 589
仅需稍微修改模板即可 即把已有通路的两点祖宗相连 #include<bits/stdc++.h> using namespace std; const int maxn=105; int fa[maxn]; struct node{ int u,v,w,x; }edge[maxn*maxn]; int cmp(node a,node b){ return a.w <b.w ; } int find(int x){ &nb...
JOURISON
2024年3月18日 10:37
继续畅通工程 题解:
P1311
回复 0
|
赞 0
|
浏览 517
仅需稍微修改模板即可: #include<bits/stdc++.h> using namespace std; const int maxn=105; int fa[maxn]; struct node{ int u,v,w,x; }edge[maxn*maxn]; int cmp(node a,node b){ return a.w <b.w ; } int find(int x){ if(x==fa[x]) ...
1935569240
2024年3月12日 10:36
继续畅通工程 题解:简单代码来了:
P1311
回复 0
|
赞 0
|
浏览 827
#include<iostream> #include<algorithm> #include<string> #include<string.h> using namespace std; //定义结点之间的连接信息 struct node { int x; int y; int fee; int status;//修建状况 }; int fa[100];//记录结点的自己的父亲 int sum...
1
2
题目
继续畅通工程
题解数量
14
发布题解
在线答疑
热门题解
1
继续畅通工程 题解:稍微修改1312
2
易理解的题解
3
继续畅通工程 题解:
4
继续畅通工程 题解:最简单的理解,你看不懂可以过来找我
5
继续畅通工程 题解:求助sos,为何通过率只有80%
6
继续畅通工程 题解:
7
继续畅通工程 题解:
8
克鲁斯卡尔
9
继续畅通工程 题解:简单代码来了:
10
继续畅通工程 题解:爆改原畅通工程