Codeforces Round #373 Div. 2 review

Link

A. Vitya in the Countryside

Basically, check last 2 character to determine its direction is “UP” or “DOWN”. Special case comes when the last number is 0 or 15, in that case the direction changes and you can determine the direction without looking second last character.

B. Anatoly and Cockroaches

We can consider 2 patterns for final alignment. Pattern 0 is to align “rbrbrb…” and pattern 1 is to align “brbrbr…”.

We will compare the original alignment and final alignment. For each position i, we need to change the color to…

  • Case A: r to b
  • Case B: b to r

If both case A and B exists, the optimal way to change color is to replace these cockroaches. and if only case A or case B exists we can change color by can. After this optimal way, the total number of count is same the maximum number of Case A & Case B.

We take smaller number of total count between pattern 0 & 1.

C. Efim and Strange Grade

The best policy to update is scan from the nearest integer and if the number is greater than or equal to 5, then round it.

Special case heppens only when the rounded value changes from 4 to 5, then we need to round this value.

So if we have ….444445…., we need to update manytimes. But if you have ….24244336…, rounding 6 one time is enough.

 

 

 

Sponsored Links

Leave a Reply

Your email address will not be published.