ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1992. CVS

Why is Java so slow? (TLE #19)
Posted by B@R5uk 21 Dec 2017 03:20
I just have implemented "Copy on Write" strategy suggested in other tread and it helped me pass through tests #9 and #10 where I got MLE/TLE earlier. But I cannot pass #19. I tried StreamTokenizer suggested by "Getting Stated" page, then I even implemented my own parser without any cheking for input errors just to speed up my solution. But still too slow!

There seems nothing can be done about algo itself: rollback/relearn fiddle with one variable, check prints, clone makes new entry in ArrayList<Clone> without actually doing anything. Only learn seems to be doing something: copying ProgramsList if it's needed, clearing abolished programs and adding new one. Not that much to find something excessive to remove.

But why it take so much time in test #19? How did 26 genii get their AC with Java? Is there some kind of trick or fundamental improvement to achive better time? I lost my mind searching solution. Please, help!

p.s. And sorry for bad English...

Update: I removed clearing ArrayList<Integer> in learn command, it waste memory a little and save time a little and made some cosmetic improvements. But still too slow!

Edited by author 21.12.2017 04:38