Скоро Codeforces Round 1133 (Div. 1, Div. 2)! Регистрация здесь. ×

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

Автор mon0pole, история, 5 лет назад, По-английски

As I didn't find any blog for this round discussion so posting this blog

Problems :

Problem 1
Problem 2
Problem 3
Problem 4
Problem 5
Problem 6

My opinion :
I found problems harder than the previous version of CodeAgon 2021.

Please share your approaches and solution for problems in comments.
PS : Sorry for unclear photos of problems (if anyone have clear photos please share them in comments)

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

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

Auto comment: topic has been updated by mon0pole (previous revision, new revision, compare).

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

This time it was smooth, no mistakes

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

Atleast this time I didn't have to guess the setter's solution XD.

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

How to solve problem 1?

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

    For every market $$$i$$$, you can either buy the oranges from the same market or go to one of the markets $$$j$$$, connected to it, get the oranges in minimum possible cost from $$$j$$$ and come back to $$$i$$$. This will incur an extra cost of $$$cost_{ij}$$$ + $$$d*cost_{ij}$$$. You can solve this using Dijkstra's algorithm. Imagine, there is a virtual node connected to all the markets and edge cost is $$$b_i$$$. Also multiply all the original edge weights by $$$d+1$$$. Problem then reduces to finding shortest path from that virtual node to all other nodes.

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

      I have seen this kind of trick somewhere. Can you please share some problem related to this trick, if you can recall?

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

        Sorry, couldn't recall any problem. But generally when I have a solution that is dp but the transitions make a graph with cycles, I try to think if updating the states in the correct order is possible through Dijkstra. So, for this problem, I initially thought $$$ans_i = min(ans_j + (d+1)*cost(i,j))$$$. Then realized that the updates are possible through Dijkstra. That virtual node is a common implementation trick, you can just ignore that and initialize $$$ans_i = b_i$$$ and then do the relaxations in Dijkstra.

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

    This is the exact same problem of Codeagon 2020. problem 1 Just replace the edge weights with cost * (D + 1). Rest everything is exactly the same. And it's more funny when you find the problem on code forces that they copied from in 2020, which they repeated now. link

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

In problem 2, I wrote dp[A][A]. dp[i][j] denotes I have written i lines and selected j lines which I can paste and then the transitions were easy. Can someone tell me was there any other obvious method to solve this problem?

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

    I was getting TLE for my solution. How do i optimise the loop inside the recursion?

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

Did anyone solve 4+ ?

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

How many could you solve? Me 4 (1,2,5,6).

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

    Can you state how to solve problem 5

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

      If you find anything wrong correct me

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

What are your approaches for problems 3 and 4? Here are mine-

Problem 3
Problem 4

If you have any suggestions and/or cases where my approaches fail, do let me know.

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

    For 3rd, I think one can simulate the following greedy procedure:

    Take the maximum element = maxx

    Pop all occurences of it, and add them to the permutation.

    Update all remaining values as x &= maxx.

    Repeat.

    You will have to do this at most 20 times.

    The reason this works is because at each step, we are selecting the lexicographically largest element according to the current active bitmask(mask of bits which have still not encountered a 0)

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

Any information about ranklist?