sprkgoyal's blog

By sprkgoyal, 5 years ago, In English

NITS Local #28

For the first time, we are posting an official editorial of the contest on Codeforces itself. We hope you like it.

Ugly Geometry

Author: invictus_123

Tutorial
Solution

Make Equal

Author: sprkgoyal

Tutorial
Solution O(nlogn)
Solution O(n)

Maximising Flow (Easy Version)

Author: invictus_123

Tutorial
Solution

Maximising Flow (Hard Version)

Author: invictus_123

Tutorial
Solution

Bruno Loves Cat

Author: sprkgoyal

Tutorial
Solution

Checker for Maximising MEX

Author: invictus_123

Backstory
Tutorial
Solution

Difference in Power

Author: invictus_123

Tutorial
Solution
  • Vote: I like it
  • +20
  • Vote: I do not like it

| Write comment?
»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Link to Contest?? :p

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

Link to the problems?

»
5 years ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

Hello! Thanks for the contest I wanted to ask about C2 I want to link my solution and I had a doubt..

My mid in the code is (l+r)/2 (which should overflow considering the extreme contraints you guys have set for the question)

Somehow it does not. https://mirror.codeforces.com/gym/282041/submission/81949734

Can anyone suggest why did it not overflow?

Also is an O(1) solution possible using a formula? Like assuming a min and taking its value out as per the formula and checking its near bounds

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    About the overflow: since you are not storing the data (l + r) which is of course out of bounds for the long long type. Instead, you are storing (l + r)/2 which fits in long long. hence you are not getting any overflow. C++ compiler can add a number upto 64 bits and then return the result. It is the variable who decides for the sign and bounds. I hope you understand what I said. And about O(1) solution. I don't know whether O(1) solution exist or not. But if you found any please share with us.