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 1322. Spy

Time Limit Exceeded
Posted by VladG 2 Oct 2006 23:08
I get "Time Limit Exceeded" error on 9 test.
Time: 0.281, Size: 424KB

I implemented Burrows - Wheeler algorithm in C++ in quite straight forward way (even without sorting).
What could be the problem and how it is possible to make it faster?
Re: Time Limit Exceeded
Posted by VladG 2 Oct 2006 23:31
I found the problem.
It was using 'string' class instead of just char array.
Probably when a string is long (100000 characters) then C++ allocate its memory in chucnks which make its access much more slower (or maybe because some limit checks).

Anyway, when I changes it to char array, it's running time was at least 10 time faster!!!