Little Ignorence may fail your code

Only one codition made my problem in topcoder’s 250 point pronlem in div 2 failed. You can view my code here http://www.topcoder.com/stat?c=problem_solution&rm=301792&rd=13898&pm=10489&cr=22692505. Can you tell what’s the value of  s.size()-2 where s is the c++ string of value 1. Many of people will answer -1 to this but actually it will give some big interger with negative value. To get value of 1 we need to typecast s.size() to integer becouse s.size assumes its value to be unsigned integer. So while writing your code sometimes these things may lead to wrong answer.

In this srm 444, I challenged one guy successfully but mine code failed. So I learned two things from this one is “We dont see our faults but we see find fault in others” and other is “We should learn from our own mistakes”.

Advertisement

~ by prashantthorat on August 5, 2009.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.