Блог пользователя pilliamw

Автор pilliamw, история, 15 месяцев назад, По-английски

90% of Python solutions to A will get hacked or fail systests, since using the obvious ans += s[i] in a loop or similar will immediately balloon into O(n^2). My question is, why would one even need to consider this for a Div2A? It's not like it even adds to the complexity of the problem — the difficulty and algorithm would be the same for $$$|s| \lt 10^3$$$ or something. At the very least, have a pretest that's the trivial print(1) print('A'*200000) generator I wrote in 30 seconds, instead of leaving that to the hacking phase.

(To be fair, I'm pretty salty right now because I dropped from 2000 to 8000 after hacking my A. But I still think this is a pretty serious problem, especially for an educational round where problems have equal weighting... unless the goal was to educate me to not use Python ever again :/)

Update: Yep, I know that Python string concatenation is rather expensive now, you don't have to keep commenting that (although I appreciate everyone who responded :D). I guess the Educational Round succeeded in being educational! I still think that there should have been a strict $$$2*10^5$$$ pretest, but whatever, I'll take the L here. Now time to get back to Expert...

  • Проголосовать: нравится
  • +43
  • Проголосовать: не нравится

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Can't you just reverse sort?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

I'll be a bore but this can educate some people that python strings are immutable and are not based on vectors, so str += char is a heavy operation

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

so what is testcase which is hacking all python submissions

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Just print all the T's first and then the other letters :)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

It is more of like lack of knowledge of Python. I too have encountered similar problem in my old days. Just use ''.join(arr) to join a list of strings it takes O(n) time. You can check it here.

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

is 'T' * cnt hackable?

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится -17 Проголосовать: не нравится

use c++ instead of python

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +9 Проголосовать: не нравится

Well, I think its pretty educational to know that strings are immutable in python. Furthermore, it seems like you did a lot more work for a problem that was just reverse sorting the string.

  • »
    »
    15 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    It's been a day and I think I'll take the L on this one lol. Still sucks that there wasn't at least a $$$2*10^5$$$ test case in pretests, but whatever. Time to get back to expert...

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I also tried to hack but there was no option for room and so that's why I leave it btw if for eg I do hack someones submission then I got extra + rating or wt? (cuz haven't done bfr so asking)

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится +26 Проголосовать: не нравится

Round is educational, and it educated you not to use += for strings

»
15 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by pilliamw (previous revision, new revision, compare).