TWO DIFFERENT O/P

http://codeforces.com/contest/149/submission/28279699
copy the code and run on local computer on (test case 38)
gives output 0.
But in Codeforces i am getting number from 36 to 59 why??
what is wrong with my code

resubmitting may be helpful…

Strange, but true.

already made 7WA attempts on the same test-case

1 Like

size of arr should be ‘Z’+1 as you are accessing up to ‘Z’.In line number 9 declare arr[‘Z’+1].
BTW if you want to know what output codeforces IDE gives and how much time codeforces IDE takes,then you can find all those by using custom invocation here http://codeforces.com/contest/822/customtest

1 Like

thanx man !! that works …made silly mistake

1 Like

Whenever you get 2 different output in C/C++ , it means your code is running on undefined behaviour. DO NOT count on judge to give SIGSEV or runtime error everytime. For some instances, it gives SIGSEV/runtime-error while at others, the same error gives undefined behaviour. At one time, i was solving a Q with segment tree and i accessed 2 x 10^5 th index in an array of 10^5 size. It didnt gave me runtime error and i had to debug it for hours before someone else pointed out the error.

Undefined behaviour is hard to detect if you only use 1 compiler, but its kind of easy to solve. Mostly its due to array index going out of bound (as hruday968 pointed out), or improper use of STL.

1 Like
//