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

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

We will hold Tokio Marine & Nichido Fire Insurance Programming Contest 2021(AtCoder Regular Contest 122).

The point values will be 400-500-600-700-800-1200.

We are looking forward to your participation!

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

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

Reminder that contest starts in 5 minutes

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

Reminder that contest starts in 4 minutes

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

Reminder that contest starts in 3 minutes

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

Reminder that contest starts in 1 minute.

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

Reminder that contest starts in 10 seconds

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

it's been 45 min and I have done NOTHING.

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

F*ckin' precision errors >:O

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

I used to treat ARCs as Div. 2 contests.

I was wrong.

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

Can we solve Problem B — Insurance , when the scenarios don't happen with equal probability?

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

C had a cancer implementation.

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

Problem D: Try and fail to write the solution by yourself. Remember there's a XOR MST problem in codeforces, google it and copy a solution from there

https://mirror.codeforces.com/contest/888/submission/32165432

https://atcoder.jp/contests/arc122/submissions/23373118 ;)

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

    I don't get the relationship between today's problem and MST. Is "the graph with edges $$$\leq x$$$ is connected" equivalent to "Bob can get a score $$$\leq x$$$"? (Why?)

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

      It isn't. We take only the edges that merge components of not both even size. Think about how things work in a trie, if you have both subtrees of even size then you'll solve the subtrees independently otherwise there'll be one number going to the other subtree and that'll dominate everything.

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

How To Lose Rating

  1. search on Google "pair with min xor"
  2. find this solution on gfg: "sort the given array, traverse and check xor for every consecutive pair"
  3. get wa
  4. debug the solution for $$$30$$$ minutes
  5. $$$2$$$ minutes to the end, realize that the solution in 2) can't be generalized if you want to find $$$\min(a_i \oplus b_j)$$$ (i.e. using, for each $$$a_i$$$, lower_bound() and upper_bound() to find the closest elements in $$$b$$$ doesn't work)
»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

how to solve C?

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

I used Fibonacci triangle rows in A

https://oeis.org/A144154

https://atcoder.jp/contests/arc122/submissions/23371678

With so many solves probably not the intended solution, but I was happy to have found the relation

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

    can you please explain the theory?is it pascal triangle?

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

      I drew some small examples of how many + and — we can have at each position. For example with 4 signs we have:

      • 5 6 6 5
      • 3 2 2 3

      for 5 signs:

      • 8 10 9 10 8
      • 5 3 4 3 5

      Assuming the 1st and last columns always contain fibonacci pairs, how to generate the ones in between? Well at each step each of the — factors will turn into + on the next turn since we cannot have two consecutive -, and also we can notice from drawing smaller examples that the number of + factors also break into fibonacci pairs — 8+ breaks into 5+ 3-, 5+ breaks into 3+ and 2- and so on.

      Then we can see in the above example 8/5, the second column is generated as

      8+ breaking into 5+ and 3-, and 5- turning into 5+

      therefore second column contains 2*5 + and 1*3 -

      similar transition happens for the next column, 2*5+ breaks into 2*3+ and 2*2-

      and 1*3- turns into 1*3+, combined that is 3*3+ and 2*2-

      and we can generalize to

      1*8 2*5 3*3 5*2 8*1

      1*5 1*3 2*2 3*1 5*1

      which are also fibonacci numbers!

      So in my solution I generate these two rows, compute each index's coefficient and add it to my result.

      This "linearity" type solution is used in the video https://mirror.codeforces.com/blog/entry/91672?#comment-803151

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

I wish I had more clarity of mind while implementing problems like C :D

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

Can someone please explain me the the implementation of dp in problem A?

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

Managed to solve C only after the contest :(

Here's my Randomised solution:

https://atcoder.jp/contests/arc122/submissions/23376359

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

When you realize, for E, that arbitrarily choosing the last element satisfying the condition works, and you spent last half hour thinking how to select last element if multiple element satisfies condition.

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

I implemented a different solution for B than the one in the official editorial. Hopefully it will prove interesting for some:

We should find minimum after x and y for: (n * x + PS[n] - PS[y] - 2 * x * (n - y)) / n, where PS[i] is the sum of the first i elements of the sorted input array. Basically, y is an index such that all elements 1 <= i <= y will provide min(A[i], 2x) = A[i] and all elements y < i <= n will provide min(A[i], 2x) = 2x. This also suggests a constraint for a fixed y: V[y] / 2 <= x <= V[y + 1] / 2.

Minimizing the formula above is the same as minimizing: n * x - PS[y] - 2 * x * (n - y) = x * (2 * y - n) - PS[y]. In order to minimize this, we can iterate 1 <= y <= n and find a suitable x. In fact, if 2 * y - n is negative, x should be as large as possible, so x = V[y + 1] / 2. Otherwise (2 * y - n is positive), than x should be as small as possible, so x = V[y] / 2.

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

How much can we rate A in terms of CF ratings ?

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

In B, I first wrote a binary search, but the ans was increasing with decreasing precision. I think, the side it was going was not correct when precision was small and numbers were large. But, ternary search was consistent on this. Can someone clarify more on this?

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

For problem B my solution tries to perform binary search to find when the derivative flips from negative to positive.

$$$f(x) = \sum\limits_{i=1}^N (x + A_{i} - min(A_{i}, 2x)) = \sum\limits_{i=1}^N (x + A_{i} - \frac{Ai + 2x - abs(A_i - 2x)}{2})$$$

$$$f'(x) = \sum\limits_{i=1}^N \frac{2x - A_i}{abs(2x - Ai)}$$$

Points where we get NaNs because of division by zero are skipped.

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

ARC E -
If one didnt realises second observation in E. Then $$$LCM_{j \neq i}(A_j)$$$ can be computed in $$$O(n \log max(A_i))$$$ using prefix and suffix LCMs with bigints.
Python Submission
Time complexity $$$O(n^3 \log max(A_i))$$$ remains same.

More specifically how did I come up with this particular solution was -
Since there exists one last no from index $$$i$$$ such that $$$LCM_{j \neq i}(A_j) \neq LCM_{j}(A_j)$$$. This python solution just brute forces to find one such index which can be last. Then recursively solves for the rest of $$$n-1$$$ numbers.

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

In D I thought it was ok to remove all pairs of equal elements initially, so that all the elements are distinct but it was failing on one test case and on removing this it passes all test cases, can someone point out a case where it fails(the test cases are not available on the dropbox yet)

WA AC

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

C:

spend hour to write solution which uses up to 250 operations, delete it, write proper solution in 15 minutes

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

.