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 1001. Reverse Root

For those who can't pass test 1 in C++
Posted by Robert Ayrapetyan 6 Jan 2014 04:17
I'm not quite sure where the problem is, but here is the story. First, I tried to submit solution which worked well on my machine (64bit OS), but test 1 was constantly failed on timus server. I've tried to change (almost) everything in my code without success. Then I started to google solutions. Surprisingly, they didn't worked either (e.g. http://helloacm.com/coding-exercise-timus-1001-reverse-root-c-solution-online-judge/ is provided as a working solution, but it also fails on test 1). I've started to think that something is broken on the timus server or I'm choosing wrong compiler version or hell knows what else. Then I've found another solution which was... accepted! Started to comparing it with mine line by line and found following:
whatever I use in scanf (llu, lld) - it works fine on my machine, but on remote server it fails. When you replace scanf by cin - it works both locally and remotely. So in short - do not use scanf for this task, use cin.
It will be very interesting to know why this happens, maybe someone could explain?
Re: For those who can't pass test 1 in C++
Posted by [ONPU-13]Asalle 2 Feb 2014 21:02
What do you mean by "not working"? WA or sth else?
As  for me, it doesn't work either way. Either scanf, or cin it's wa1, I don't know why.
Pechal'
Re: For those who can't pass test 1 in C++
Posted by yeahin 25 Mar 2014 09:37
Right, somehow sscanf("%lld") doesn't work.  Use strtoll() instead.