Блог пользователя vilcheuski

Автор vilcheuski, 5 лет назад, По-русски

Привет, Codeforces!

Приглашаем вас на Codeforces Round #765 (Div. 2), который пройдет в 12.01.2022 15:05 (Московское время). Обратите внимание на необычное время проведения раунда. Этот раунд будет рейтинговым для участников, чей рейтинг ниже, чем 2100.

У вас будет 2 часа на решение 5 задач, одна из которых будет разбита на простую и сложную версии. Раунд основан на задачах третьего этапа республиканской олимпиады по информатике в Беларуси. Просьба всех белорусских школьников, участвовавших в третьем этапе, воздержаться от участия в раунде и обсуждения задач публично до конца раунда.

Огромное спасибо тем, кто помог сделать этот раунд:

  • Нашим координаторам KAN и isaf27 за замечательную координацию раунда.
  • Wind_Eagle, gepardo, VEGAnn, andrew за помощь в подготовке раунда.
  • programmer228, Vladik за тестирование раунда.
  • MikeMirzayanov за прекрасные системы Codeforces и Polygon.

Разбалловка: 500-1000-1500-2000-(2000+1250)

Всем удачи!

UPD: Наконец-то готов разбор.

  • Проголосовать: нравится
  • +297
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +50 Проголосовать: не нравится

Wish you all good luck & high rating!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Good luck! I wish every grey become green!

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +4 Проголосовать: не нравится

The round is based on the problems from Belarusian Regional olympiad.

Does it mean that the round has many OI-style problems?

If someone can answer me, thanks in advance.

»
5 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится -15 Проголосовать: не нравится

Finally a good old div2 with 5 problems. Can't wait for it!

Wish everyone good luck

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

Wish everyone good luck!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

It's a pity that I can't participate, good luck everyone who can!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Let's go, good luck!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +2 Проголосовать: не нравится

Oh, i will solve this problems tomorrow at 9:00 AM(i from belarus):D

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Two contests on the same day damnn!!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Looking forward to participating and performing well.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Как раз еще одна тренировочка перед регионом :)

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thank you for this amazing round!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +28 Проголосовать: не нравится

Every Monogon follower after seeing a recent CF Round Announcement: 'Not gonna lie, I spent the last one hour thinking of a smart comment that would get many upvotes.'

Together we can stop this. Donate by upvoting my comment.

(I may or may not be a Monogon Follower)

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +20 Проголосовать: не нравится

Yey,First div2 contest in the new year,Wish everyone good luck!

Meme
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +174 Проголосовать: не нравится

all Belarusian pupils

all Belarusian specialists can do whatever they want

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Why has the Magic tab not disappeared yet ?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

Are the problems completely the same as the Belarusian Regional Olympiad or they are just based on them?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -66 Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Great! The score distribution announced very early!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -24 Проголосовать: не нравится

Please, make problem B easy, so newbies can solve it

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +65 Проголосовать: не нравится

Wish you all good luck & high rating!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Nyaharoo~~

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +41 Проголосовать: не нравится

essayforces!

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +30 Проголосовать: не нравится

who all like non-theme based contests wherein the problem statements are easy to understand and one dont have to spent extra 10-15 just to grasp the statement fully?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

I want to bid for the modern art painting of Problem C.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

What was that with problem A man? Almost gave me a heart attack xD

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +2 Проголосовать: не нравится

Also, I hate Jupiter & its moons now XD

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +13 Проголосовать: не нравится

Why so strict memory limit for problem C? :(

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

not able to solve single problem :/

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +40 Проголосовать: не нравится

I hate long statements

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

thanks to problem A i could now probably go to sleep with 0 submissions

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

I love pretest 5 on problem C

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Long statements really consumes lot of time.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится -73 Проголосовать: не нравится

    Yes, but they are more clear and contain more explanations, so you most likely will understand the problem from the first read.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится +40 Проголосовать: не нравится

      actually they are not more clear the story is not useful, i mean shorter statement is better

      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +28 Проголосовать: не нравится

        Would it be better if we rewrote the statements as

        Given an array $$$a$$$ of $$$n$$$ $$$\ell$$$-bit integers, find an $$$\ell$$$-bit integer $$$y$$$ such that $$$\sum\limits_{i=1}^n d(a_i, y) \to \min$$$, where $$$d(x, y)$$$ is Hamming distance.

        I tried my best to make the rewrite above as short as possible, without omitting essential details.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится +13 Проголосовать: не нравится

      Yes, but they are more clear and contain more explanations.

      Exactly, but this applies only if statements actually contain explanations, rather than random planet's moon.

      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +42 Проголосовать: не нравится

        I know that I don't hold the popular opinion here. Still, I want to show that the problem A mostly contained detailed explanations, rather than "random planet's moon". See yourself:

        Image

        As you can see, the legend part is no more than a third of the statements, while the other part is actually explanations.

        To prove my point about clearer statements further, I want to say that this contest had much smaller amount of questions than other recent rounds I helped setting. The number of questions was even ~1.5 times smaller than my old Codeforces Round from five years ago, where the number of participants was ~3 times smaller than now.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      actually no

      im pretty sure short statements are easier to understand than long ones

      long statements are confusing and unclear

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +81 Проголосовать: не нравится

Anyone else ?

problem A
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

How to solve problem B ??

Can someone help & tell me if my logic is wrong here : https://codeforces.me/contest/1625/submission/142496857

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Why is the memory limit for C so strict?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +20 Проголосовать: не нравится

ReadAlotForces

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

Is it just me or contest these days are really hard?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

Is there any greedy solution for problem C?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

How to solve D?

  • »
    »
    5 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится +18 Проголосовать: не нравится

    Special case: if $$$k = 0$$$, the answer is all indices from $$$1$$$ to $$$n$$$ inclusive. Hereafter we assume $$$k \neq 0$$$.

    Partition the values $$$a_i$$$ into groups according to the prefix of bits higher than $$$k$$$'s most significant bit. Observe that you can consider each such group individually, as any two values from two different groups will xor into a prefix that's greater than $$$k$$$'s most significant bit.

    Now in each group, we can always choose at least one member, and at most two members, because if we choose more than two, there will be two values that will xor to zero in the position of $$$k$$$'s most significant bit, thereby producing a value less than $$$k$$$.

    To find out if we can choose two values from a group, we find the pair with the maximum xor and compare it with $$$k$$$. Finding the maximum xor of two numbers in an array is a well-known problem (but you'd need to modify the algorithm on this page so that you know the indices of the pair) and can be done in $$$O(m \log k)$$$, where $$$m$$$ is the number of values in the group. Therefore the total time taken over all groups will be $$$O(n \log k)$$$.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    Observation is that a minimum value of $$$a_i \oplus a_j$$$ is achieved at some two adjacent numbers after sorting.

    After sorting, you can write simple dynamic programming, $$$dp_i$$$ — the length of the longest subsequence that ends with $$$i$$$. Transitions are very simple $$$dp_i = max$$$ {$$$dp[j]+1$$$}, where $$$a_i \oplus a_j \geq k$$$.

    It can be optimized using trie.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

That 128MB memory limit on Problem C was tricky.

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

What's the expected time complexity for problem c ? my O(n*k^2) dp solution was giving tle.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +127 Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Can someone please give me hint for C?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why aren't you allowing $$$log(n)^2$$$ solutions to pass in D?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Has anyone solved B via Binary search ?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why did I pass the code sample locally, but not in codeforces ?

Spoiler
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Some hints for D please.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +71 Проголосовать: не нравится

I like problem D, but why $$$k=0$$$...

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится +10 Проголосовать: не нравится

Спасибо за рисунки! Они шикарны! :-)

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

A hint for Problem E2:

Spoiler
  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Maybe an interesting extension for type 1 queries is to guarantee that $$$s[l+1 \dots r-1]$$$ is an RBS.

    Spoiler
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can you solve E1 with MO's algorithm?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

Cheater in my room. She his/her code for C: here

»
5 лет назад, скрыть # |
← Rev. 3  
Проголосовать: нравится -6 Проголосовать: не нравится

The most miserable thing for python users during the contest: Figure

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +18 Проголосовать: не нравится

A very nice contest ruined with long problem statements

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone help me in problem B,wrong answer at pretest 4

Basically selecting minimum difference indices of same character than adding count of elemnts before first appearence and after elements of second appearence

ans = x[0] + n — x[1];

Code
»
5 лет назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

The idea of Problem D is good. Not only observation but also a specific technique is required to solve it. However, I think it is too hard for Div.2D. Due to the difficulty of this technique, it should be somewhere around Div.2E. Also, the corner case $$$k = 0$$$ is tricky.

The technique required to solve D
  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +15 Проголосовать: не нравится

    Trie is not needed if you make use of the observation that choosing elements with different msb (most significant bit) are independent and to consider which elements of the same msb should be chosen, we just need to switch off the msb and consider the subproblem recursively.

    At the last step, when the msb becomes smaller than or equal the msb of $$$k$$$, we can make use of this to check whether there exist a pair of numbers whose xor exceeds $$$k$$$, and if otherwise we just pick any random number.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What is wrong with this logic for D: let i = leftmost set bit of k, right shift each element by i-1. Output the no. of unique elements after the right shifts.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone, who was able to solve Problem C walk me through the recursive->Memoization->Top-Down/Bottom-Up solution? I am learning DP right now and could not understand the code of other participants. Would really help me a lot...

  • »
    »
    5 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +5 Проголосовать: не нравится

    Let $$$dp(i,j)$$$ = min time to reach $$$d_i$$$, by removing $$$j$$$ signs. Assuming $$$d_n=l$$$, the answer is minimum of $$$dp(n,j)$$$ over all $$$j \lt =k$$$.

    Recursion: Consider computing $$$dp(i,j)$$$. One candidate for $$$dp(i,j)$$$ is $$$dp(i-1,j) + a_{i-1}*(d_i-d_{i-1})$$$. But it's possible that we removed the $$$(i-1)$$$th sign, so we drove at speed $$$a_{i-2}$$$ from $$$d_{i-2}$$$ all along, so $$$dp(i-2,j-1) + a_{i-2}*(d_i-d_{i-2})$$$ is another candidate. Continuing with this reasoning, and also noting that we could not have removed more than $$$j$$$ signs, we get the recurrence:

    $$$dp(i,j) = min_{p \lt =j} dp(i-1-p,j-p)+(d_i-d_{i-1-p})*a_{i-1-p})$$$.

    Base case is of course $$$dp(0,*)=0$$$.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

pretests were deadly :(

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why is my solution for C giving WA verdict? 142521905

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +1 Проголосовать: не нравится

    Among all possible (ans, prev) in dp[i-1][j-1], there might be such pair that the ans is bigger while the prev is smaller and it is better to transition from that pair.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
      ← Rev. 2  
      Проголосовать: нравится 0 Проголосовать: не нравится

      Will you please elaborate more? Will this case arise only when temp1==temp2 has been happened previously?

      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
        ← Rev. 2  
        Проголосовать: нравится +1 Проголосовать: не нравится
        4 100 2
        0 1 5 6
        1 2 3 100
        

        Your dp[3][1] should be 8(5+3, removing the 2nd), because if we remove the 3rd, the ans will be 1+2*5, which is worse.

        And prev[3][1] will be 3 because the 3rd is not removed.

        But the best transition is when dp[3][1]=11 and prev[3][1]=2.

        • »
          »
          »
          »
          »
          5 лет назад, скрыть # ^ |
           
          Проголосовать: нравится +1 Проголосовать: не нравится

          Thank you Ji_Kuai, I was also struggling with the same thinking what's wrong in it. Thanks to nyet for replying me with the link of this comment.

          But I am curious, like can't we do anything to this approach to get it better. Like at any (i,j) if we store all the possible (ans,prev) pair and using the one to calculate for further states. Tho it's more complex and inefficient. But can we do that? Will that give the right answer?

          And making the conclusion that "for calculating some new dp state, the stuff we are using for it must be unique in the sense that that stuff should be only valid stuff for that previous state" is right or wrong?

          • »
            »
            »
            »
            »
            »
            5 лет назад, скрыть # ^ |
             
            Проголосовать: нравится 0 Проголосовать: не нравится

            For the first question. It is obvious that for any pair (ans, prev), (a, b) is always better than (c, b) if a < c (the ans is smaller and prev is equal).

            If we use dp[i][j][prv] instead of dp[i][j] and store the smallest ans, it will be correct(But this will get MLE in this problem).

            • »
              »
              »
              »
              »
              »
              »
              5 лет назад, скрыть # ^ |
               
              Проголосовать: нравится 0 Проголосовать: не нравится

              Okay, one more, Just the last one Ji_Kuai, please! Why can't we make dp[currBoard][prevBoard] storing the minimum time currently on currBoard and the last board taken be prevBoard && maxCan[currBoard][prevBoard] storing the k value when we were there. Now my claim is that dp[currBoard][prevBoard] will update only when currMaxCan is greater the maxCan[currBoard][prevBoard] or when it is not updated yet!

              My code link -> 142507920

              • »
                »
                »
                »
                »
                »
                »
                »
                5 лет назад, скрыть # ^ |
                 
                Проголосовать: нравится +1 Проголосовать: не нравится

                I think your claim is correct. But it doesn't mean that you can return dp[curBoard][prevBoard] when curMaxCan is less than maxCan[curBoard][prevBoard].

                When the curMaxCan is less than maxCan[][], the return value for that should be greater since you can not close as much station as the stored dp value.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +32 Проголосовать: не нравится

Ratings updated preliminarily. We will remove cheaters and update the ratings again soon!

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

If you were stuck at a problem <=C, Here are the video solutions,

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +52 Проголосовать: не нравится
  • Suggestions on problem D: Stop making ORIGINAL PROBLEMS.

I think testers should realize that, because this problem is very classical and is obviously an original problem.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +62 Проголосовать: не нравится

    for red guys only :)

  • »
    »
    5 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +1 Проголосовать: не нравится

    I don't think problem setters should avoid classical problems in div2 and div3. Div 2 and 3 are "educational" contest. Although problem D uses classical idea, not everyone (especially experts and below) have seen it before, and they can learn in this contest, which is good for them to study.

    The problem is good to use if only you are not able google the problem by the statement online.

    • »
      »
      »
      5 лет назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      I don't think problem setters should avoid classical problems in div2 and div3. Div 2 and 3 are "educational" contest.

      I thought Educational Codeforces rounds were created as "educational" contests, not the regular Div. 2 rounds.

      • »
        »
        »
        »
        5 лет назад, скрыть # ^ |
         
        Проголосовать: нравится +9 Проголосовать: не нравится

        Yes, there is educational contest, although the frequency is not much. But since problem D is a master level problem (difficulty rating > 2100), I think it's OK to use it in the div 2 since red and orange users are unrated.

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Hello, no, I don't realize that. When I solved this problem, I did not remember anything like that.

    Moreover, I liked this problem more than all the others I have solved in the original contest.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In case anyone else is struggling with TLE in problem D with Java, I needed to do both of the following to make it fast enough:

  • Don't store each number once for each bit i.e. each trie node should only contain a single number. During the step where you need to find all the numbers under a node, you'll need to run a separate DFS to get them all.
  • Don't use objects. Use preallocated arrays as "fake" objects (e.g. https://codeforces.me/contest/1625/submission/142532132)
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

LONG STATEMENTS made bad reading experience.

A good contest anyway.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Video Editorial for Problem C: Road Optimization

I explain my 2 dimensional dynamic programming solution along with the intuition for why DP is used (and not greedy) and how one can come up with the recurrence.

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

https://codeforces.me/contest/1625/submission/142524915

Want to know what is wrong with my approach

My approach for C was as follows:

  1. I find the index of all the signs, which when removed decrease the total time.

  2. Now I just need to choose at max k of these candidates for removal.

  3. this is where DP comes in, I apply it on the preselected candidates.

IF while choosing value of current k>0 than I have 2 option

1.)either choose to remove(insert index in a set named removed)

2.)Ignore and move to next candidate

ELSE Ignore and move to next candidate

for base case after completely going through all the candidates , I have a set of chosen sign's indices(i.e signs which should be removed). So considering that these set of removed signs as not being present, I calculate the total time taken and return it.

I memozized this using a dp[501][501] array.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +19 Проголосовать: не нравится

Here is slightly harder version of problem D. Source: this comment.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

printf("Codeforces Round #765 (Div. 2)");

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

bruh imagine waking up at 4am on US west coast to do div2 contest, just to give up after 15' of trying to read problem A.

»
5 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

How do you quickly find out whether we should use greedy algorithms or DP for optimization problems like C? The only clue that I found for C is the input size: 500. This might imply that we can use O(n^3) DP. If I don't know this size, I might spend time on thinking about possible greedy solutions.

(By the way, I didn't participate in this contest but I read and solved A, B, and C. I think they are interesting problems.)

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Solve dp problems on timus for 3 days straight prior to the contest lol, totally not me

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    The simple answer is that if you can't prove your greedy solution, you can't be sure it works. In this case it's reasonably easy to construct a counter-example; in other cases it's more difficult. If you can't prove greedy and you can see a DP solution, it's likely to be safer.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

Problem E2 is very interesting! I love this problem.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

where tutorial? in tourist's stream?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can problem C use Convex Hull Optimisation to solve it?

  • »
    »
    5 лет назад, скрыть # ^ |
     
    Проголосовать: нравится +21 Проголосовать: не нравится

    Yes, I solved it with convex hull after the contest.

    Code : https://codeforces.me/contest/1625/submission/142559648

    dp[i][j] is min time required to reach ith city using j road signs. So the transition is like dp[i][j] = min (m<i) dp[m][j-1] + (d[i]-d[m])*a[m]

    The transition part can be written as a line like y = dp[m][j-1]-d[m]*a[m] + d[i]*a[m]

    The slope is a[m] and the intercept is dp[m][j-1]-d[m]*a[m]. We can pass in d[i] and get the minimum using convex hull trick.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +10 Проголосовать: не нравится

thrilling round :)

Spoiler
»
5 лет назад, скрыть # |
 
Проголосовать: нравится +14 Проголосовать: не нравится

excellent round with strong samples and pretests.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I could attempt only 2 problems and now my rating went down ;-;. How2 time management on easy questions. Aaaaaaa I wanna get to green so bad.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone find problem in my code for problem D i am getting WA on test case 14. I am using bit trie, sorting and segment tree. after sorting if i am at indx i than first i will find the maximum element such that it's xor with current element is greater than or equal to k. Now i used dp since we can select any element which is less than maximum element(mx) so i made a segemnt tree on values of dpi's. dp[i]=max(dp[j]+1) for all j such that a[j]<=mx Then to update value of current element we just query of the prefix from 0 to mxid(index of maximum element) dp[i]=query(0,mxid)+1;

Code

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +27 Проголосовать: не нравится

where can i get editorials to this contest

»
5 лет назад, скрыть # |
 
Проголосовать: нравится -19 Проголосовать: не нравится

Can anyone guide / help / suggest me on how to reach expert (1600+) rating at codeforces...... I am currently specalist.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Could someone please explain why greedy wouldn't work for C?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Some hints for people stuck at debugging problems C and D.

anonymouspegion

Input
Expected Output
Your Output
Comment

Dev_Manus

Input
Expected Output
Your Output
Comment

_Enginor_

Input
One Valid Output
Your Output
Comment
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Any hint for Problem D

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

when is the editorial? i think beluorusian regional olympiad has it, because for example in russia, we have editorials right after the contest

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I don't know if the authorities can see it. It is the first time FOR me to play CodeForces, because I handed in the same code with this number and my trumpet and was targeted by the authorities. I hope you can listen to my sincere explanation.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I don't know if the authorities can see it. It is the first time FOR me to play CodeForces, because I handed in the same code with this number and my Tuba and was targeted by the authorities. I hope you can listen to my sincere explanation.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is it possible to do C in O(n^2)?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Where editorial ? Where banana?

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why is the editorial so slow?