|
|
вернуться в форумAC; after little bit tweaking the code I got TL#4 Послано ile 26 мар 2010 01:55 This is ridiculous!! My AC solution (ACed twice) works in 0.950 seconds. Which is actually O(n^2). The code is long and nasty... After some "improvements" - ie changing ArrayList to LinkedList/getting rid off BitSet/etc - the running time should decrease drastically!! but it gives me TL... WTF? I was sure, that my "better" code works FASTER, since there is much less operations to perform... Can anyone help me with it? I can send the code to get feedback. Thanks! 0,015s And I'm interesting how to solve this in 0,015s. Re: 0,015s Послано ile 27 мар 2010 00:26 well... There's good idea in neighbor thread, which proves that solution always exist. It can help you solve it in O(n). Or... you can think up your own ideas based on remainders... There's up to N remainders only... so I used BFS without considering duplicates... it works fast enough in Java. Re: 0,015s Yeah, there is a nice idea. =) Re: 0,015s 0.14 seconds on JAVA, O(nlogn + n) solution |
|
|