HDU 1879 继续畅通工程
来源:互联网 发布:如何把淘宝微信群做大 编辑:程序博客网 时间:2024/05/02 02:09
已经修好的路一定要往里面加
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;struct Edge{ int from,to,dist,status; bool operator < (const Edge temp)const { if(status != temp.status) return status > temp.status; else return dist < temp.dist; }}e[5050];int fa[105];int Find(int x){ if(fa[x] == x) return fa[x]; fa[x] = Find(fa[x]); return fa[x];}int main(){ int N; while(scanf("%d", &N) != EOF && N) { int n = N*(N-1)/2; for(int i = 0; i < n; i++) scanf("%d%d%d%d", &e[i].from, &e[i].to, &e[i].dist, &e[i].status); sort(e, e+n); for(int i = 1; i <= N; i++) fa[i] = i; int ans = 0; for(int i = 0; i < n; i++) { int x = Find(e[i].from); int y = Find(e[i].to); if(x == y) continue; else{ fa[x] = y; if(!e[i].status) ans += e[i].dist; } } printf("%d\n", ans); } return 0;}
0 0
- HDU 1879 继续畅通工程
- 继续畅通工程 hdu 1879
- hdu 1879 继续畅通工程
- HDU 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879 继续畅通工程
- HDU 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879 继续畅通工程
- HDU 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu - 1879 - 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879 继续畅通工程
- hdu 1879(继续畅通工程)
- hdu 1879 继续畅通工程
- Axure之进度条的实现
- 申请自考学士学位终于不再参加一年一次的全省申请学士学位外语统一考试了.
- AOP编程之前置通知
- HDU 4910 / BC 3D Problem about GCD
- #1039 : 字符消除
- HDU 1879 继续畅通工程
- 开发中遇到的问题
- Codeforces Round #355 (Div. 2)E. Vanya and Balloons
- android6.0 wifi连接
- matlab中关于pushbotton的左键双击响应问题
- LeetCode刷题之路 - number 26 and number 9
- iOS中常用的几何方法
- 字符集的前世今生
- 1013 Problem M