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

Автор chokudai, история, 20 месяцев назад, По-английски

We will hold AtCoder Beginner Contest 272.

The point values will be 100-200-300-400-500-500-600-600.

We are looking forward to your participation!

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

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

my favourite

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

How to solve task E?

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

    Just keep incrementing the i-th element by (i+1) and put them into a set for each m. Need to speed up the process by only caring about the cases where the number just becomes 0 and smaller than n. My solution

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

      I'm not able to get the intuition on why it will fit in the time limit :/

      Any hints regarding the same?

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

        Because first element is used at most n/1 times, second — n/2 times and so on. So, in total maximum sum over all answers = n * (1/1 + 1/2 + ... + 1/n) ~ n * log(n).

»
20 месяцев назад, # |
Rev. 4   Проголосовать: нравится 0 Проголосовать: не нравится

Actually I don't think problem F fits for its position, it would be better to swap it with G indeed.

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I tried using BFS in Problem D, but I am not able to pass the 3 tests. Can someone help me find the issue? https://atcoder.jp/contests/abc272/submissions/35485981

»
20 месяцев назад, # |
Rev. 2   Проголосовать: нравится -20 Проголосовать: не нравится

On problem D, I think it will be possible to solve the problem in $$$O(N^2+\sqrt{M})$$$ by precalculating the possible movements. (I did it in $$$O(N^2+(\sqrt{M})^2)=O(N^2+M)$$$ through a brute-force precalculation.) Did anyone solve D with this method also?

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

    I also first enumerated the possible moves, but I did so by enumerating all $$$(i, j)$$$ s.t. $$$i, j \in [-N, N]$$$, which takes $$$O(N^2)$$$ to enumerate them.

»
20 месяцев назад, # |
Rev. 3   Проголосовать: нравится +1 Проголосовать: не нравится

I used the SA-IS algorithm in problem F but failed. I thought my idea was genius but the jury thought I was an idiot. Would you please review it?

Submission(272F)

  • »
    »
    20 месяцев назад, # ^ |
    Rev. 2   Проголосовать: нравится +1 Проголосовать: не нравится
    Spoiler
    • »
      »
      »
      20 месяцев назад, # ^ |
        Проголосовать: нравится 0 Проголосовать: не нравится

      Before reviewing it, I first pressed the upvoting button.

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

      Yes, there are counterexamples.

      Let $$$T=\texttt{"dcbaf"},\,S = \texttt{"afdcb"}$$$.

      Here is my code:

      string s1 = s, t1 = t;
      s1.pop_back();
      t1.pop_back();
      string large = t + t1 + s + s1;
      

      In my concatenation, the large is $$$\texttt{"dcbafdcbaafdcbafdc"}$$$. The first $$$\texttt{"fdcba"}$$$ starts from No.4 (0-indexed) whose suffix is $$$x=\texttt{"fdcbaafdcbafdc"}$$$, the second $$$\texttt{"fdcba"}$$$ starts from No.10 whose suffix is $$$y=\texttt{"fdcbafdc"}$$$. $$$x < y, j=4, i=1$$$. My algorithm would not count this pair but this pair is definitely valid.

      For the correct answer, please refer to the tutorial/editorial.

      This is the link to the original problem (ABC272F Two Strings).

      Welcome to my blog about ABC272F: https://codeforces.com/blog/entry/107776.

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

I think problem E is very nice for "learning how to analyze complexity". In fact during contest, I could not convince myself that the complexity is O(NlogN) rather than O(NM), but after reading the editorial, I really like the idea of "important values".

Besides, problem F is somehow about suffix array, which is really really a difficult topic for me, not even to talk about that clever construction in editorial. It seems that I should find time to learn suffix array again.

»
20 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone explain how hashing solution works for F?

I am not able to think how to compare strings lexicographically using it

»
20 месяцев назад, # |
  Проголосовать: нравится +8 Проголосовать: не нравится

Can someone explain for problem $$$G$$$ why we need to check only $$$log_{3/4}(1-L)$$$ times randomly according to the editorial?

  • »
    »
    20 месяцев назад, # ^ |
      Проголосовать: нравится +16 Проголосовать: не нравится

    Let $$$ P(success) = L $$$

    $$$ P(failure) = 1-L $$$

    $$$ P(failureInOneRound) = 1-\frac{1}{4} = \frac{3}{4}$$$

    We fail only if we fail on all steps. Let the number of steps be x, then

    $$$ P(failure) = P(failureInOneRound)^x = (\frac{3}{4})^x$$$

    On equating P(failure) you'll get the desired value of $$$ x = \log_\frac{3}{4}(1-L) $$$

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

      Its probably a dumb question but how is $$$P(success) = 1/4$$$. I mean they said it in the editorial but how did they arrive at this conclusion?

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

        S = Subset of array which will be in answer. |S| $$$ \geq \lfloor \frac{n}{2} \rfloor + 1 $$$. For getting correct answer we want that both values which are chosen must belong to S. Its probability, p = $$$ \frac{|S|*(|S|-1)}{n*(n-1)} $$$.

        $$$ |S|*(|S|-1) \geq (\lfloor \frac{n}{2} \rfloor+1)*(\lfloor \frac{n}{2} \rfloor) \geq (\frac{n}{2})^2-(0.5)^2$$$ (-0.5 term will come when n is odd) $$$ \geq \frac{n^2-1}{4} \geq \frac{n^2-n}{4}$$$

        Substituting in p, we get p $$$ \geq \frac{1}{4} $$$