Happy Summer Vacation The first question of the online programming contest: Split point game

Source: Internet
Author: User

Theme:

N-node, M-Bar-free graph. Each node has a weighted value of W. Defines the cost of removing a node as the sum of the weights of the nodes adjacent to it. After removing a node, delete all the edges connected to the node. The minimum cost of removing all nodes. Input Description: Input includes multiple test data. The first line of test data in each group is first entered N,m (1?≤?n?≤?10000; 0?≤?m?≤?20000). The second line enters N integer wi (0?≤?wi?≤?105), followed by M-line. two integers per line U. V for node U is connected to V (1?≤?ui,?vi?≤?n; ui?≠?vi). Output Description: For each set of test data. The minimum cost of the output to remove all nodes.


Idea: Just read the question, thought the problem is more difficult, and then think about not know how to do, and then consulted others, did not think the idea will be so simple.

We get a weight for each side of the line. according to the node weights from large to small delete. This allows the weight and the minimum of all sides, that is, the minimum cost to think about the amount.


Code: Slightly .....

Happy Summer Vacation The first question of the online programming contest: Split point game

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.