Codeforces Round #305 (Div. 1)

Source: Internet
Author: User

547a-mike and Frog

Solution:

The first and second changes to the time of the target are calculated first for two changes.

A few special sentences are needed for the specific circumstances of these four times.

Then enumerate the multiples of one of the times directly from 1 to 2*n, and then output the first answer that satisfies the requirement.

Or we can find out the minimum solution by expanding Euclid in the cycle.

547b-mike and Feet

Test instructions

Given a sequence of length n (<=2*10^5), the maximum value of the minimum number of intervals of length (1~n) is calculated respectively.

Solution:

The longest interval with each number as the answer can be preprocessed first.

That is, from each number from left and right to find the first position less than its number, you can use the monotone stack O (n) processing.

Suppose that the left or right of X is l,r. Then the value of interval 1~ (r-l+1) can be taken to X for Max. Actually just update ans[r-l+1], and finally to Ans[i]=max (Ans[i],ans[i+1]). It's all right.

Time complexity O (n)

547c-mike and Foam

Test instructions

Each time you add or remove a number from a sequence (up to 2e5), the number of coprime in the output sequence. (ask no more than 2e5)

Solution:

The principle of tolerance and repulsion.

You can preprocess the approximate number of each, record cnt[x], and the number of multiples of x in the current sequence.

Then use the allowance to calculate the effect of deleting or adding this number to the answer.

547d-mike and Fish

Solution:

Graph theory.

Because the topic has been guaranteed to have a solution. It is important to note the specific nature of this guarantee.

It can be found that only points of the same row or column can affect each other, including indirectly in the same rows.

Then, for rows and Liegianto, according to the column to the node marking, need to put the fish point into the edge.

So the set of points that can interact with each other is connected. The following only needs to be dyed on edges.

In such a connected diagram, the difference between the sides of a different color that needs to satisfy an arbitrary point connection is less than or equal to 1.

If the different color edges as a point of the out and into the edge, the problem becomes the Euler road to find this figure.

Codeforces Round #305 (Div. 1)

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.