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 1350. Canteen

Are there any suffix spaces in input?
My prog gets TLE on test #17. The complexity of my prog is 100*100*log100, so it can't be that it really runs too slow. The only possibility is that it falls into an infinite loop when performing binary search for a food name, because the string inputted contains suffix spaces. Admins please correct this and rejudge the prob if this is true.

Edited by author 10.01.2006 03:41
Re: Are there any suffix spaces in input?
Posted by Vladimir Yakovlev (USU) 9 Jan 2006 17:37
It can't be solved in  100*100*log100 because input may be as large as 100*100*40. Don't you read the whole input?
Re: Are there any suffix spaces in input?
Posted by Maigo Akisame (maigoakisame@yahoo.com.cn) 10 Jan 2006 03:41
It doesn't matter. 100*100*log100*40 is about 3e6, which is still not big enough to lead to TLE.
Re: Are there any suffix spaces in input?
Posted by Vladimir Yakovlev (USU) 10 Jan 2006 04:16
You made a very tricky mistake.
You compare string[40] and string 100*100*log100 times. This comparison works very slow because string[40] is casted to string every time.
Re: Are there any suffix spaces in input?
Posted by Maigo Akisame (maigoakisame@yahoo.com.cn) 10 Jan 2006 15:00
Thanks. You're right. When I changed 'string' into 'string[40]' I got AC very fast.