Codeforces round #167 (Div. 2 & div.1)

Source: Internet
Author: User

Div2 A: Water question

Div2 B: change each number to 1. the required number of steps is the F value of this number (the odd number minus one and the even number is divided by 2)

Div1 A: record the highest current height.

Div1 B: Sb question, there will be many points with the same X coordinate, but there may be some key points, so multiply the CNT! /(2 ^ c). Because the total CNT size cannot exceed 100000, it is acceptable for each brute force operation. At first, I was wondering if there were any modulo obtaining skills .....

Div1 C:
It seems to be the original question. I will give you a picture. Each vertex has no more than three degrees. You need to divide the vertex into two groups, so that no vertex in each group has> = two adjacent contacts in the same group.

Solution: assume that all vertices are in the same group, and then constantly find invalid vertices in the two groups and put them in another group (just search for them)

Proof: assume that the total number of edges with the same color as the two dots is m, and an invalid vertex u is found each time. There are three situations:

1: U has three adjacent contacts and the color is the same as U, then u into the opposite color will make M-3

2: U has two adjacent contact color and U is the same, another difference, then u into the opposite color will make the M-1

3: u only has two adjacent contacts, changing u to the opposite color will make M-2

To sum up, changing an invalid point to the opposite color will reduce the number of M, so the number of running algorithms is at the O (m) level.

Code


PS: the above two questions are both tests of the computing complexity capability, but the brute-force algorithms are actually not.

Div1 D:

Div1 E:

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.