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

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

1613A - Длинное сравнение

Идея: BledDest

Разбор
Решение (awoo)

1613B - Отсутствующий остаток

Идея: BledDest

Разбор
Решение (Neon)

1613C - Отравленный кинжал

Идея: BledDest

Разбор
Решение (Neon)

1613D - MEX-последовательности

Идея: BledDest

Разбор
Решение (Neon)

1613E - Сумасшедший робот

Идея: BledDest

Разбор
Решение (awoo)

1613F - Раскраска дерева

Идея: BledDest

Разбор
Решение (BledDest)
  • Проголосовать: нравится
  • +88
  • Проголосовать: не нравится

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

In my opinion , E might be a little easier than D , so I recommend swapping D and E .

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

Neat and Clean explanations especially on F. Thank you!

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

This was a great contest, learned about FFT technique from problem F which seems quite useful

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

great problems! great editorial! I learnt a lot.

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

i wrote this dp solution for problem D

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

Problem F can be solved in $$$O(n\log n)$$$ time:

Spoiler

There is also an much more complex algorithm that solve F in $$$O(n)$$$:

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

damn those are some very elegant solutions

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

I don't understand why the runtime is $$$O(n \log^2 n)$$$ in problem F.

We can write the divide and conquer runtime as $$$T(n) = 2 * T(n / 2) + O(n \log n)$$$. This is case 3 in the master theorem of divide and conquer which yields $$$T(n) = \theta(n \log n)$$$, no?

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

    Do you have an implementation? This sounds cool.

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

      I didn't solve this problem, I'm simply reading the solution from the editorial and wondering why their implementation is $$$O(n \log^2 n)$$$ instead of $$$O(n \log n)$$$.

      I think my mistake is probably that the 3rd case of the master theorem doesn't apply here, and the master theorem cannot be used. To use the master theorem case 3 there must exist a constant $$$\epsilon \gt 0$$$ such that $$$n \log n = \theta(n^{1 + \epsilon})$$$, and it might not exist.

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

        Because the $$$f(n) = \Theta(n \log(n)) = \Theta(n^{c_{crit}} log(n)^1)$$$, this recurrence actually falls in case 2 of the master theorem (if you hold on the order of cases in wikipedia). This solves to a running time of

        $$$T(n) = \Theta(n \log(n)^{1+1})$$$

        .

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

          I was referring to the cases from CLRS (page 94) and the case 2 is more specific there, and it doesn't fall into it.

          Indeed if I look at Wikipedia the case 2 is more generic and it does apply in this case, thanks!

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

In problem D,Why the ans should become ans — 1?

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

    We initialize $$$dp1_{0,0}$$$ with a $$$1$$$, which represents an empty subsequence (which has MEX equal to $$$0$$$). At the end we accumulate the answers and count it in. Since we are asked to count only non-empty subsequences, we should subtract it.

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

I cant understand why the number of colorings that meet $$$k$$$ choosen violations is $$$(n-k)!$$$ in problem F, can someone explain it in more details please?

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

    I can give an intuitive idea behind that. For every violated constraint, a node of the tree is already defined by its parent (it's just their parent's number minus one). So basically out of the $$$ n $$$ nodes, we can focus on the $$$ n - k $$$ nodes which aren't tied to their parents and think about the relative order between them.

    Let's build a sequence of these untied nodes in which the first node has the highest value $$$ n $$$, the second the next highest value and so on.

    Of course you can choose any of them to have the highest value $$$ n $$$, then choose any other node to have the next highest value (which depends on the previous node as it might have induced the value $$$ n - 1 $$$ to one of its children and maybe more values to its descendants) and so on. The thing is you can choose any of the untied nodes to go next in this sequence. Therefore you can have any possible relative order between them, so the number of colorings is $$$ (n - k)! $$$

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

I feel like F should have a "divide and conquer" tag based on what's written in the editorial, is it really so? UPD: Thanks for adding the tag, hope it will help people in their practice later ^_^

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

Extremely well written and explained solutions kudos for that!:)

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

Can someone help me in E, 137783013 it keeps getting TLE but it's just a BFS.

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

One thing I can't understand in the tutorial for D: The tutorial says that [0,0,1,1,1,2,3,3] is a MEX-correct sequence. However, this violates the definition of MEX-correctness. For example, let i = 7. Now MEX(0,0,1,1,1,2,3) = 4. |0 — 4| = 4, |1 — 4| = 3, and |2 — 4| = 2. These are all violations of MEX-correctness as described in the question. May you elaborate on how the above sequence is MEX-correct?

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

https://atcoder.jp/contests/abc213/tasks/abc213_h The above problem from atcoder have the solution where one has to apply DNC FFT stuff. While The Problem F seems like a polynomial multiplication where one prefers to multiply shorter polynomial first. We can do it along the similar line of merge-sort or simply use priority queue and multiply shorter polynomials each time. 137796885. How is it DNC FFT? (Or what is DNC FFT exactly?)

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

I couldn't understand the editorial this much but can I solve E like this?? we implement a bfs or dfs from lab and just change to + the cells of grid which we can control and we can reach them with a path from the lab that we can control?? we can control means that the cell has two paths or less.

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

    You can start a BFS from the lab. Mark lab as + for generalization sake. During bfs, do the following: 1. If a cell you are looking at has at most one neighbour cell which is not blocked and not with plus, then mark that cell as +. 2. If a cell is marked + now, push all of its neighbour cells to the queue unless the neighbour cell was visited from this particular cell. In other words, keep visited not just for some cell, but for a parent-child relationship. If cell a already pushed cell b to a queue, then don't let a to push b again, but some other cell c can still push b. 3. Go to the next queue element. Pretty sure there is no way to solve this problem using DFS.

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

Thanks to div2, I became a pupil

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

Can anyone please tell me what's wrong in my submission for E?

I am getting TLE on : 137850453 Also this is the exact same solution which got passed in about 200 ms : 137675491

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

Good problems and contest) Nice problem B btw

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

In problem E (Crazy Robot) I am getting wrong answer over test case 8

My solution:- https://codeforces.me/contest/1613/submission/137885700

If anyone can help me out

Thanks in advance

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

[deleted]

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

Thanks for the great editorial for D!

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

Thanks for the great editorial for D!

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

I can't get why are we printing "r + 1" answer in question C and not simply "r".

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

    Hey, this has simply got to do with the way the binary search was written. From the code, you can see (thanks to the if else) that the variable r will be the greatest value for which the sum will be < h. You can understand this as: if the sum >= h, then r = r-1. So r will be lowered until it reaches the optimal solution-1. There is actually another way to write this binary search. In my solution, I wanted "lo" to be the smallest value such that the sum would be >= h. Link to my solution: https://codeforces.me/contest/1613/submission/138581286 I hope this is clearer to you now! Do not hesitate to reply if it is not clear enough :)

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

Can anyone please help me , Why am I getting memory limit exceeded on 8th test case in problem E ? https://codeforces.me/contest/1613/submission/138290812

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

In 1613D — MEX Sequences, for the 1st test case, why [0,2,1] is not in the answer? MEX([0,2,1]) = 3 0 — 3 = -3 <= 1 2 — 3 = -1 <= 1 1 — 3 = -2 <= 1

So the correct answer should include: [0], [1], [0,1], [0,2], [0,2,1]

Thanks for any hint. If I understand it correctly, in the last test case:

0 1 2 3

The answer should include:

[0], [1], [0,1], [0,2], [0,1,2], [0,1,3], [0,1,2,3]

Please correct me if I am wrong.

Thanks heaps :D

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

    [0 2 1] is not correct

    in ith step we get mex from (x1, x2.... xi)

    i = 0; we have (0) now mex is 1. so |0-1| = 1 <= 1.. right. i = 1; we have (0, 2). now mex is 1. so |2 — 1| = 1 <= 1.. right. i = 2; we have (0, 2, 1). now mex is 3. so |1 — 3| = 2 > 1... wrong;

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

D is the most felt hard dp problem I have ever solved till today