Codeforces Round #704 Div2 Solutions - Implementation problems

This round of Div2 is easier than average. Every problem is not so complex. Most of them are thinking or implementation problem. Not hard, just have many small logics.

I'm so weak...

E. Almost Fault-Tolerant Database

It is a problem of thinking ability. Just consider the scenario of n=2 and extend it to other situations.

Codeforces Round #704 Almost Fault-Tolerant Database - Enumeration + Implementation
SolutionLet’s consider the scenario $n=2$. Because at most change two elements. So the most number of different points is 4.

D. Genius's Gambit

Just a simple construction problem. The most complex part is not how to construct it but how to implement it after I know how to construct.

Codeforces Round #704 Genius’s Gambit - Implementation + Construction
SolutionBetter to be classified as implementation problem. Lots of details. Get Lots of WA.Attention: You are not allowed to use leading zeros for $x$ and $y$.
Click here for details solution.

C. Maximum width

Solution

Greedy. Find the $p$ with the number as large as possible and $p'$ with number as small as possible.

The $p$ match from right to left, so that can make $p_i$ largest. Similarly, $p'$ match from left to right, so that can make $p'_i$ smallest. Then the maximum width is: $\max\limits_{{1}\leq{i}<{m}}{(p_{i+1}-p'_i)}$。

Code

Submission #112088897 - Codeforces
Codeforces. Programming competitions and contests, programming community

The sample data and I are too weak. It can pass the sample data even I forgot read the input at all.


B. Card Deck

Solution

Greedy. Pick the card with maximum value from remain deck.

Because of the coefficient in front is $n^{n-1}$! Which is a very huge number.

Code

Submission #112086846 - Codeforces
Codeforces. Programming competitions and contests, programming community

A. Three swimmers

Solution

Take remainder for everyone. If one of remainder is 0, then need 0 second. Otherwise original time minus reminder is the time needed to wait this person.

Code

Submission #112085816 - Codeforces
Codeforces. Programming competitions and contests, programming community
DigitalOcean Referral Badge 蜀ICP备19018968号