zoukankan      html  css  js  c++  java
  • BZOJ1083: [SCOI2005]繁忙的都市

    水题之王SP…这题就裸的最小生成树

     1 /**************************************************************
     2     Problem: 1083
     3     User: zhuohan123
     4     Language: C++
     5     Result: Accepted
     6     Time:32 ms
     7     Memory:1404 kb
     8 ****************************************************************/
     9  
    10 #include <iostream>
    11 #include <cstdio>
    12 #include <algorithm>
    13 using namespace std;
    14 struct edge
    15 {
    16     int u,v,c;
    17     friend bool operator<(edge a,edge b){return a.c<b.c;}
    18 }g[11000];
    19 int f[310];
    20 int gf(int p){return f[p]==p?p:f[p]=gf(f[p]);}
    21 int main(int argc, char *argv[])
    22 {
    23     int n,m;scanf("%d%d",&n,&m);
    24     for(int i=1;i<=n;i++)f[i]=i;
    25     for(int i=1;i<=m;i++)scanf("%d%d%d",&g[i].u,&g[i].v,&g[i].c);
    26     sort(g+1,g+m+1);
    27     int bmax=0;
    28     for(int i=1;i<=m;i++)
    29         if(gf(g[i].u)!=gf(g[i].v))
    30         {
    31             bmax=g[i].c;
    32             f[gf(g[i].u)]=gf(g[i].v);
    33         }
    34     printf("%d %d
    ",n-1,bmax);
    35     return 0;
    36 }
  • 相关阅读:
    Visio2019专业版激活方法
    I2C总线协议
    latch-up和Antenna-effect
    读--数字集成电路物理设计
    数字IC设计流程与工具
    读--FPGA设计指导原则
    读--数字集成电路设计与实现
    FIFO
    半导体存储器
    触发器
  • 原文地址:https://www.cnblogs.com/zhuohan123/p/3258526.html
Copyright © 2011-2022 走看看