paxaq's blog

By paxaq, history, 17 months ago, In English

My slow solution 291665439 to 2031D - Penchick and Desert Rabbit passes the system tests.

Explanation
  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
17 months ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

my O(n^2) brute force solution 291699055 also got accepted for 2031B - Penchick and Satay Sticks

  • »
    »
    17 months ago, hide # ^ |
    Rev. 3  
    Vote: I like it +6 Vote: I do not like it

    This is actually a valid $$$\mathcal{O}(n)$$$ solution. With the if condition any element will not move more than one place from the initial order so the loop never runs more than twice through the entire array.

»
17 months ago, hide # |
Rev. 2  
Vote: I like it 0 Vote: I do not like it

Sir, teach us your skill of optimizing code!