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

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

We will hold NOMURA Programming Contest 2021(AtCoder Regular Contest 121).

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

We are looking forward to your participation!

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

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

why did so many reds fail to solve D? I think it was very ez lol

my code

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

Bruhhh... I just did some random shit for C XD
Can anyone explain their solution?

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

My code for B is getting RE on 15 cases. Can somebody help please? I implemented simple two-pointer technique. My Code for B...

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

Am I the only one who felt like B's implementation was cancer? Can anyone share their neat implementation?

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

    My implementation gave runtime error on 15 cases. Can you share yours?

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

    I find min difference of between B & G , B & R and R & G separately. Then we have to deal just for 1G & 1R or 1G & 1B or 1B & 1R.

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

    My solution is here

    Let $$$b_i$$$ store all $$$a_j$$$ with $$$c_j = i$$$ (with R = 0, G = 1, and B = 2)

    If all $$$b_i$$$ are even, we can pair dogs within the same color and have to left over, so the answer is $$$0$$$.

    Otherwise, there are two indices $$$i$$$ and $$$j$$$, with $$$b_i$$$ and $$$b_j$$$ even. We can try combining two dogs from $$$b_i$$$ and $$$b_j$$$ (with two pointers or binary search). Let $$$k$$$ be the other index that's not $$$i$$$ or $$$j$$$. Notice that combining two dogs from $$$i$$$ and $$$k$$$ and then two more from $$$j$$$ and $$$k$$$ might be better. So you can just try the best ones from $$$i$$$ and $$$j$$$, and the answer is the minimum of this sum and the previous answer.

    Also, there are no edge cases, you can prove that.

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

    Code

    We will end with one of 2 cases, all colors are even or 2 of them are odd.

    The first case has answer 0, but the second has one of two cases to find the minimum answer, you can try to match each element from any of the two odd sets with the nearest one to it in the other set or you can take two elements from the even set and try to match them with the nearest two from the odd sets.

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

    I felt that B was a pretty nice, Atcoder-quality problem. But they didn't have the other case in the samples, which probably screwed a lot of people over.

    For me, A was like cancer. Here's my wack implementation. Those whole 50 minutes were like "Why doesn't this work... Why does it work now?"

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

    Mee toooo

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

    https://atcoder.jp/contests/arc121/submissions/22994246

    This legend really writes the neat code, worth to go through it.

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

solved B, but failed to solve A, and wasted the whole contest. does anyone have a similar experience?

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

What was the hand_01.txt test case for problem A

UPD : Hello camypaper sir, please give me that test file.

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

Does anybody has any idea why this code tles in 2000ms in problem E on exactly one test file while this code passes in 20ms (just some small constant optimizations)? .It cost me 30 minutes of penalty

edit:found the mistake

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

What a dumbhead I am, my D's solution is equivalent to the standard one if all $$$a_i \gt 0$$$, and is wrong otherwise. But my stress test data generator only generated data with $$$a_i \gt 0$$$ so I couldn't find the mistake!

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

D has a nice idea but it really seems to be harder than standard-ish E.

D: If we choose which elements to use as part of a pair, then we should pair the first with last etc. That's because if $$$a \le b \le c \le d$$$, then $$$c+d,b+d \le b+c,a+d \le a+c,a+b$$$ — it gives us the tightest intervals [min,max] not just by max-min, but in each value separately. How to deal with $$$k$$$ unpaired elements? Just add $$$k$$$ elements equal to $$$0$$$, then everything is paired. We can bruteforce for each possible $$$k$$$.

E: Inclusion-exclusion DP. For each $$$k$$$, we're looking for the number of subsets of $$$k$$$ vertices which violate the given condition, while ignoring the condition on the remaining $$$N-k$$$. Merging DP for subtrees is convolution-like and when we have a subtree of $$$v$$$ with size $$$s_v$$$, where we put $$$k$$$ of its descendants into the subset, then there are $$$s_v-1-k$$$ values we can't use for $$$a_v$$$ in the permutation if we put $$$v$$$ in the subset too.

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

My C solution fails with 1 WA in small case 1. Can anyone help me debug? I tried all permutations up to size 10. It does the job within N*N.

My Code

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

My Idea For C : Besides The array Having Permutation , Used One More array for Storing Position . Now to Idea is to start Bringing the elements 1 2 3 ... respectively to their position i.e 1 2 3... one by one if(position[i]==i) move ahead for next i otherwise the position of i must Be greater Than i . Now if parity of step_number and position of i are same we can during this step select any index (definitely the one for which parity with step_number is same ,I selected position[i] +2 or position[i]-2) other than position[i] for this step without destroying the initial set sequence upto i-1 . After This the parity of step_number and position[i] become different and we can bring i to index i in position[i]-i steps .But what I said above is will be possible only if position[i]+2<=(n-1) or position[i]-2>=i Otherwise the initial set permutation upto i-1 will have to be changed . To Tackle this we can use the following 5 sequence steps : let x=position[i]-2. x x+1 x x+1 x after these five steps both i and i-1 will get their sorted Position . . we can Use This Examples Sequence to understand This : Permutation = 1 3 2 , steps = 5 indices 1 2 1 2 1. It converts into 1 2 3 (1 and 2 both get their Sorted Position) Here is my submission : https://atcoder.jp/contests/arc121/submissions/23010036 Very Sad That I solved It just by 19:30 submitted without compiling on my ide , It gave CE and just after correcting that it gave AC

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

A very simple observation on problem F:

It's always better to make AND operations first.

Thus a tree is good if and only if after all OR edges are removed, at least one component is all $$$1$$$.

You can also prove this by induction.

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

Allowing houses in problem A to have identical coordinates was a cruel and unusual punishment!

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

The official editorial for D is too good!

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

My solution to D is equivalent to the editorial solution, but I think it is a little easier to think of (though the editorial solution is really nice). The observation is that the elements that are taken alone need to be in one consecutive block if we sort $$$A$$$ first. With some precomputation with some sparse tables, it's easy to check all possible consecutive blocks in $$$\mathcal O(N^2)$$$. I have linked my submission below.

Submission

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

I have some doubts in E — Directed Tree

  • The editorial say that " Also, let dp(i,j) be the number of ways to write numbers in the subtree rooted at i so that j positions are violating the conditions" so why dont we take dp (1,0) as our final answer because we need to count the way that "the subtree at 1 and 0 position violate the rule" isn't it ?

But sadly it is not correct to take just dp (1,0) as our final answer