ccf 201703-4 地铁修建
来源:互联网 发布:mac手绘软件有哪些 编辑:程序博客网 时间:2024/04/28 05:38
http://118.190.20.162/view.page?gpid=T54
并查集,类似最小生成树的套路
#include<iostream>#include<vector>#include<algorithm>using namespace std;int pre[100005];int findroot(int index) { if (pre[index] != index) pre[index] = findroot(pre[index]); return pre[index];}void _add(int a, int b) { int x = findroot(a); int y = findroot(b); pre[x] = pre[y] = min(x, y);}class AA {public: int a, b, c; bool operator<(const AA x)const { return c < x.c; }};vector<AA> all;int main(){ int n, m; cin >> n >> m; AA x; while (m--) { cin >> x.a >> x.b >> x.c; all.push_back(x); } sort(all.begin(), all.end()); for (int i = 1; i <= n; ++i) pre[i] = i; for (int i = 0; i < all.size(); ++i) { _add(all[i].a, all[i].b); if (findroot(n) == 1) { cout << all[i].c << endl; return 0; } }}
阅读全文
0 0
- ccf 201703-4 地铁修建
- 201703-4 地铁修建 ccf
- CCF 201703-4 地铁修建
- CCF-CSP 地铁修建 JAVA 201703-4
- CCF 201703-4地铁修建(SPFA)
- CCF 201703-4 地铁修建 Java
- 地铁修建——CCF CSP 201703-4
- ccf 201703 4-地铁修建(100分)
- CCF 2017-03-4 地铁修建
- ccf地铁修建
- CCF CSP 地铁修建
- CCF 地铁修建
- ccf 修建地铁
- ccf-地铁修建
- 地铁修建 CCF
- ccf-2017034地铁修建
- ccf csp 地铁修建
- 第十次ccf 地铁修建
- Inductive Representation Learning on Large Graphs 论文阅读
- 德国制造商从特朗普的税收计划中看到了利益
- spark
- STM32模拟IIC读写24CXX
- checkstyle检测后的修改方法
- ccf 201703-4 地铁修建
- Linux (CentOS 7.3) 下快速安装Mysql数据库
- 全志R16 Tina SDK V2.1 编译
- springMVC通过getBean()获取context.xml文件中定义的service接口类
- 搭建hadoop集群环境
- view.performClick()触发点击事件
- 拼多多面试之--实现一个百度搜索框
- 马克鳗使用
- Android 组件化