GOJO_GOKU_KURAMA's blog

By GOJO_GOKU_KURAMA, history, 2 years ago, In English

https://mirror.codeforces.com/contest/1945/problem/H

Hey cfers hope all are doing well can anyone please tell me how to solve this please do share your code and logic thanks.

  • Vote: I like it
  • +8
  • Vote: I do not like it

»
2 years ago, hide # |
Rev. 2  
Vote: I like it +1 Vote: I do not like it

Hints for reaching the solution

1945H - GCD is Greater

Solution
Implementation details

I was in a hurry during the contest, so my implementation was not much neat, here is it anyway 252257639.

This was all but, if somebody have any questions, I will be happy to answer.

  • »
    »
    2 years ago, hide # ^ |
    Rev. 2  
    Vote: I like it 0 Vote: I do not like it

    we don't need to store the cnt[bit

    True. But if you do store it, your implementation will become a lot simpler. If you have the count of zeroes at each position, then, when you remove $$$a[i]$$$ and $$$a[j]$$$ from the set, you simply decrease the count by $$$0$$$ or $$$1$$$ or $$$2$$$ (depending upon whether the outgoing element has that bit set or unset). Then, if the count is zero, the bitwise AND would contain $$$1$$$ at that position. We can repeat for each bit.

    Sample Submission

  • »
    »
    2 years ago, hide # ^ |
     
    Vote: I like it +3 Vote: I do not like it

    Thank you

»
2 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

I've added hints for H : GCD is Greater on CF Step