SRM 670 div2 ABC

Source: Internet
Author: User

A Cdgame

Brute force ...

B drbalance

Greedy, at the top of each selection-becomes +, equivalent to all negative +2.

C Treestrat

Consider concentrating on catching a red token, taking the token as the root of the tree, and the subtree of the root of the token in B is not going to go, (the tree is very important)

And there will be more and more nodes that cannot be reached. Find the shortest distance from the node in B to any point V on the tree d[v], when and only if the distance of red token to V is less than d[v]

Before you can go to V. Choose one of the biggest d[v] as the answer to this red token. All red tokens take min.

Code

SRM 670 div2 ABC

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.