TwentyOneHundredOrBust's blog

By TwentyOneHundredOrBust, history, 5 years ago, In English

https://codeforces.net/contest/1237/submission/62742100

Looks N^3, but seems to be N^2 after constructing many cases. Any proofs/can you hack it?

»
5 years ago, # |
Rev. 2   Vote: I like it -23 Vote: I do not like it

You can try this input:

2000
2000 0 0
1998 0 0
  ...
4 0 0
2 0 0
1 0 0
3 0 0
  ... 
1997 0 0
1999 0 0
»
5 years ago, # |
  Vote: I like it +104 Vote: I do not like it

Something like this makes your algorithm work in $$$O(n^3)$$$ time. You need $$$O(n)$$$ points on each diagonal:

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

    In contest I submitted the same idea but I was sorting first.

    my submission

    I tried (CUSTOM INVOCATION) it passed your testcase in 31ms, I also believe that it remains O(N^3). How it pass all testcases and your testcase ? mnbvmar