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

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

We will hold Mynavi Programming Contest 2021(AtCoder Beginner Contest 201).

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

We are looking forward to your participation!

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

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

How to solve today's D ?

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

How to solve E in faster than O($$$n^2$$$)? If LCA is intended, why ask dist to be calculated as XOR?

Edit: Thanks Matua, Corrected the error

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

Thanks for that TL on E. Reminded yet again how dangerously slow vector push_back can be smh

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

How to solve D ? Could only do A,B,C,E :(

Here are my solutions,

A
B
C
E

UPD: I was getting DM's to explain my approach in E here it is,

Notice that there is only 1 path from u to v in a tree.

Next this path is passes through the LCA of u,v in that tree.

So $$$d(u,v)$$$ $$$=$$$ $$$d(u,ROOT)$$$ $$$\oplus$$$ $$$d(LCA(u,v),ROOT))$$$ $$$\oplus$$$ $$$d(v,ROOT)$$$ $$$\oplus$$$ $$$d(LCA(u,v),ROOT)$$$

The LCA term gets xorred twice and becomes 0 and we are left with only ROOT distances which can be precomputed.

So essentially we have to find :

$$$res$$$ $$$=$$$ $$$\sum\limits_{i=1}^{n}\sum\limits_{i=1}^{n}{{d[i]}\oplus{d[j]}}$$$

Which is a standard contribution technique problem.

Notice that it will count pairs (d[i],d[j]) and (d[j],d[i]) twice so in the end multiply $$$res$$$ by modular inverse of 2.

For D I thought of some dp of pairs but could not get it to work.

UPD : Thanks for sharing your approaches in D :D

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

    D is a dp problem. Try to think with states row and column where you start and dp[row][col] stores the maximum difference you can get from there. This can be easily correlated to maximum differences from the row+ 1,col and row, col + 1.

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

    D

    dp[i][j]: max{score of first — score of second } starting from (i,j)

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

Can E be solved using Centroid Decomposition?

Also, E was available online. Link

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

Thanx got the mistake.

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

    Probably overflow on line 117. The term $$$aa$$$ could go upto $$$10^{10}$$$ (when half the bits are zero, half are odd). You are multiplying $$$10^{10}$$$ with $$$2^{60}$$$ without applying modulo first.

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

I took a much longer route for E. I used dp. Calculated the number of times a bit can occur and not occur in the paths from node to other node in its subtree. This can be related to the bit distributions from child. Using this, here I calculated the number of times a bit occurs if we consider one node from two different child subtree. Also, the contribution if we consider the present root and any other node in its subtree.
and then adding the contribution from each node, will give the ans. Submission

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

Can someone tell me Why I am getting WA on E? I had used same approach as Editorial. Submission

Edit: got it. Changed "ans=(ans+z*(dp[i]*dp1[i])%mod)%mod;" to ans=(ans+(((z*dp[i])%mod)*dp1[i])%mod)%mod; to get AC, Overflow maybe happening

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

Can anyone tells what's wrong with my solution with problem D,I think that the idea is similar to the editorial,I fail even I change the direction of iterating. My submission's link:https://atcoder.jp/contests/abc201/submissions/22620773

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

how to solve C using Permutations and combinations?

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

    I tried it with PNC and was getting many cases. I guess this problem was meant to bait with PNC and the solution was brute force instead.

    If there is a PNC solution , please tell

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

.

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

Did anyone manage to pass TL in problem E with Centroid Decomposition?