zoukankan      html  css  js  c++  java
  • HDU

    Destroy Walls

    Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 132768/132768 K (Java/Others)
    Total Submission(s): 1774    Accepted Submission(s): 689


     

    Problem Description

    Long times ago, there are beautiful historic walls in the city. These walls divide the city into many parts of area.

    Since it was not convenient, the new king wants to destroy some of these walls, so he can arrive anywhere from his castle. We assume that his castle locates at (0.6∗2√,0.6∗3√).

    There are n towers in the city, which numbered from 1 to n. The ith's location is (xi,yi). Also, there are m walls connecting the towers. Specifically, the ith wall connects the tower ui and the tower vi(including the endpoint). The cost of destroying the ith wall is wi.

    Now the king asks you to help him to divide the city. Firstly, the king wants to destroy as less walls as possible, and in addition, he wants to make the cost least.

    The walls only intersect at the endpoint. It is guaranteed that no walls connects the same tower and no 2 walls connects the same pair of towers. Thait is to say, the given graph formed by the walls and towers doesn't contain any multiple edges or self-loops.

    Initially, you should tell the king how many walls he should destroy at least to achieve his goal, and the minimal cost under this condition.

     

    Input

    There are several test cases.

    For each test case:

    The first line contains 2 integer n, m.

    Then next n lines describe the coordinates of the points.

    Each line contains 2 integers xi,yi.

    Then m lines follow, the ith line contains 3 integers ui,vi,wi

    |xi|,|yi|≤105

    3≤n≤100000,1≤m≤200000

    1≤ui,vi≤n,ui≠vi,0≤wi≤10000

     

    Output

    For each test case outout one line with 2 integers sperate by a space, indicate how many walls the king should destroy at least to achieve his goal, and the minimal cost under this condition.

     

    Sample Input

    
     

    4 4 -1 -1 -1 1 1 1 1 -1 1 2 1 2 3 2 3 4 1 4 1 2

     

    Sample Output

    
     

    1 1

     只能说读题很难,我太难了。我给大家画个图解释一下样例。

    这个国王被围起来,他要访问它所有的城市,必然要拆遍,不然出不去,就是说拆掉多少遍,使图成为联通的,也就是说不会保留环即可,无论这个国王在哪,这个图只要有环,就不能遍历,所以跟每个点的坐标没有任何关系,直接剔除环中的最小边,但是这样对吗?我们要使剃边花费最小,那么就要使剃边后剩下的无向无环图的边权和最最大,因为剔除环中最小边,不能保证提出的和最小,所以一遍最大生成树。

  • 相关阅读:
    bcdedit /copy {current} /d "xxx" 报错,提示找不到系统文件
    Moving docker images location to different partition
    docker 使用save和load命令来转移image
    docker image rm ubuntu 失败
    yum国内镜像配置
    VMware下安装CentOS7 无法通过桥接模式进行联网
    docker大概理解
    windows cmd 切换磁盘
    使用Git向GitHub上上传代码
    抛砖引玉——进程和线程的理解方式
  • 原文地址:https://www.cnblogs.com/lunatic-talent/p/12798727.html
Copyright © 2011-2022 走看看