You are not logged in. Please login at www.codechef.com to post your questions!

×

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

asked 04 Jul '17, 17:50

popo_popo333's gravatar image

3★popo_popo333
154
accept rate: 0%

edited 04 Jul '17, 17:53

Strange, but true.

(04 Jul '17, 17:57) c_utkarsh5★

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

link

answered 04 Jul '17, 18:05

hruday968's gravatar image

4★hruday968
1.7k210
accept rate: 14%

edited 04 Jul '17, 18:11

1

thanx man !! that works ...made silly mistake

(04 Jul '17, 18:22) popo_popo3333★

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.

link

answered 04 Jul '17, 18:52

vijju123's gravatar image

5★vijju123 ♦♦
15.4k12066
accept rate: 18%

edited 04 Jul '17, 18:53

resubmitting may be helpful...

link

answered 04 Jul '17, 17:56

abhikalpu_123's gravatar image

5★abhikalpu_123
1475
accept rate: 8%

1

already made 7WA attempts on the same test-case

(04 Jul '17, 18:01) popo_popo3333★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×678

question asked: 04 Jul '17, 17:50

question was seen: 306 times

last updated: 04 Jul '17, 18:53