5

Codeforces Round #840 (Div. 2) and Enigma 2022 — Cybros LNMIIT Editorial

 1 year ago
source link: https://codeforces.com/blog/entry/110278
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
By SoCloseButStillSoFar, 3 days ago, In English

We hope you liked the problems! Unfortunately, problem C turned out to be harder than usual. Please read its editorial, we hope you'll find that the intended solution is not that hard.

1763A - Absolute Maximization

Idea: DreadArceus
Prepared by: DreadArceus

Hint 1
Hint 2
Need more hints?
Solution

1763B - Incinerate

Idea: gupta6007
Prepared by: gupta6007

Hint 1
Hint 2
Solution 1
Sort by power solution
Solution 2
Sort by health solution

1763C - Another Array Problem

Idea: .utk.
Prepared by: .utk.

Hint 1
Hint 2
Solution
Brute force solution
Case work solution

1763D - Valid Bitonic Permutations

Idea: warks
Prepared by: warks

Hint 1
Hint 2
Hint 3
Solution
Code

1763E - Node Pairs

Idea: crimsonred
Prepared by: nobita1729, DreadArceus, crimsonred

Hint 1
Hint 2
Solution
Code

1763F - Edge Queries

Idea: nobita1729 DreadArceus
Prepared by: nobita1729 DreadArceus

Will be posted soon.

24 hours ago, # |

Anyone got the DP solution for D please?

  • 23 hours ago, # ^ |

    Rev. 2  

    +19

    from tourist's submission

    lets have dp[l][r] as number of ways we can construct our array from l to r, with elements [n-(r-l+1)+1, n] (basically (r-l+1) of highest distinct elements) regardless of K

    the next element we are gonna put is n-(r-l+1), so we try to extend out dp to the left and to the right to calculate dp[l-1][r] and dp[l][r+1]. Do not forget to check if the element we put next is valid to restrictons given wth (i, j, x, y)

    • 11 hours ago, # ^ |

      I understood the solution of D that is provided in the editorial. But trying to understand the dp approach for the same. I saw many solved it by dp but not able to get my head around. Please explain anyone.

    • 6 hours ago, # ^ |

      Rev. 2  

      0

      Can you please tell why we always choose "(r-l+1) of highest distinct elements"?

23 hours ago, # |

Rev. 2  

+11

How does the validator for F work? I tried the Petersen graph (https://codeforces.com/contest/1763/hacks/878513) and the validator accepted it, but I believe it does not satisfy the condition of the problem statement. Did I input the graph wrong, or is it actually a valid test case?

After some more experimentation, I feel that either I have grossly misunderstood the precondition as described in the problem or the validator is completely inconsistent with that precondition.

  • 22 hours ago, # ^ |

    Hey, thanks for pointing this out.

    The validator for problem F removes bridges and then ensures that all the subgraphs remaining have no articulation points. This is enough to fail all the graphs that will cause solutions to the problem to fail.

    The Petersen graph doesn't have a Hamiltonian cycle and thus fails the condition given in the statement but will not fail any solutions or the validator.

    Since we cant find Hamiltonian cycles in all the subgraphs efficiently, the validator is made like this. According to the statement, the Petersen graph should fail though, sorry for the confusion.

    Do you have any suggestions to improve the validator?

    • 22 hours ago, # ^ |

      Thanks for the explanation. The condition in the problem statement seems like it might be infeasible to check. Probably the correct thing to do would have been to use a different condition or disallow hacking.

      • 22 hours ago, # ^ |

        We had wanted to disable hacking but, in the end, thought that this validator would be enough. We were only thinking about the cases that cause solutions to fail and overlooked graphs like these.

        Sorry for the inconsistent validator. We will do better next time!

22 hours ago, # |

editorials with hints are appreciated:)

22 hours ago, # |

Is it rated ? Rating changes are rolled back without notice..

  • 20 hours ago, # ^ |

    Did you find out why it happened? I'd really like those points back :(

    • 19 hours ago, # ^ |

      They are removing the cheaters ! :) they will come back

21 hour(s) ago, # |

I think it is impossible to write a validator for F. I think that for graphs that are connected enough such that each two vertices share a circle,it is still hard to find whether there exists a hamilton circle.

  • 21 hour(s) ago, # ^ |

    I think that biconnected graphs are enough to satisfy my condition,and finding a hamilton cycle for such graphs is equivalent with finding one in any graph.

21 hour(s) ago, # |

Rev. 5  

0

When calculating ifac[i] we can calculating each (fac[i]^(mod-2))%mod individually, with time complexity is O(n*log(mod)), which may cause TLE when n is large. We can just calculate ifac[n]=(fac[n]^(mod-2))%mod, and ifac[i]=ifac[i+1]*(i+1)%mod, where i iterate from n-1 to 0, with complexity O(n+log(mod)), which is reduced to about 1/30.

20 hours ago, # |

In problem C, solution, first paragraph, should be .

  • 19 hours ago, # ^ |

    Thanks. Fixed it.

19 hours ago, # |

The author seems to be simulating the attacks in problem B, but since health can be up to a billion, couldn't simulating the attacks with a while loop cause TLE? In my case I used the quadratic formula to avoid this problem. What am I missing here?

  • 18 hours ago, # ^ |

    The problem statement states that . The power of each monster is at least . If there are still some monsters alive, will decrease by at least every iteration. If reaches zero before all monsters die, the answer is "NO". Thus, the loop will run for a maximum of iterations per test case before reaches zero, and since there are at most test cases, the loop will run for iterations in total at maximum, well within the time limit.

    • 18 hours ago, # ^ |

      Thanks, makes sense.

      • 17 hours ago, # ^ |

        I like your solution, although more difficult to implement. Could you explain how you come up with it ?

        • 16 hours ago, # ^ |

          I needed a way to calculate the number of attacks necessary to kill a given monster, but I hadn't noticed the subtlety that vgtcross pointed out, so instead I found a formula for the amount of damage dealt over m attacks, given Genos power level. Then I solved for m such that the damage dealt was equal to the monster's health, h, and took the ceiling of the solution as my number of attacks. Then Genos power level was reduced accordingly and I moved on through the list of monsters.

19 hours ago, # |

I think you meant a suffix array there in problem B health solution.

15 hours ago, # |

I m doing the following solution for the problem B but it is giving WA on pretest 5 for 47th test case I am not able to figure out what is the mistake. Can anyone here help me out?

186097185

15 hours ago, # |

Problem D, Mistake (typo) in first para of solution and spoiler under Hint1.

Fix
  • 14 hours ago, # ^ |

    Thanks for pointing it out! Will correct it.

  • 14 hours ago, # ^ |

    Thanks! Fixed now.

12 hours ago, # |

Just curious.. How to solve D with the bonus constraints ?

  • 12 hours ago, # ^ |

    Use binomial formula: sum(C(n,k))=2^n where k=0 to n

  • 7 hours ago, # ^ |

    You may refer to this comment. A similar approach was also described by satyam_343 during testing as well. Hope this helps :)

12 hours ago, # |

Thanks for such a amazing round guys :)


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK