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

×

wrong answer on c++ 4.3.2, but works on c++ 11

An interesting problem, i just came about! I once read a question from a user. He had a WA on "THE NEXT PALINDROME" . I told him his code doesn't output a right answer for an already palindrome string, eg:-9999. Acc to me it gave an output 9999 but it should be 10001. But he kept arguing that it always gave the correct output on his compiler. Apparently today i submitted the code in c++11 and to my shock, it did give a right answer. Its the same code. I just copied and pasted. Nothing more. Also went line by line to check if there was something I was missing. I am clueless though. Can someone tell me the reason with a proper explanation and a way to avoid it?

Problem link :- http://www.codechef.com/problems/PALIN C++4.3.2 code link :- http://ideone.com/MQXjKN C++11 code link :- http://ideone.com/jxb1BS

asked 14 Oct '14, 02:16

pranjalranjan's gravatar image

4★pranjalranjan
2.0k21432
accept rate: 20%

edited 14 Oct '14, 02:17

1

code courtesy :- hellboy054 :p

(14 Oct '14, 02:20) pranjalranjan4★

Make the two arrays global in c++ 4.3.2 .Maybe c++ 4.3.2 can't handle this much stack memory usage...not sure though.

link

answered 14 Oct '14, 02:55

fauzdar65's gravatar image

2★fauzdar65
29114
accept rate: 21%

Nope! Dint work still! Something else you can figure out?

(14 Oct '14, 02:56) pranjalranjan4★

what case is it failing now?

(14 Oct '14, 03:02) fauzdar652★

It fails always on c++ 4.3.2. But it never does on c++11. Same cases as before.

(14 Oct '14, 03:02) pranjalranjan4★

when i put the two 10^6 sized char arrays outside of main, it worked for me

(14 Oct '14, 03:04) fauzdar652★
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:

×54
×25
×6

question asked: 14 Oct '14, 02:16

question was seen: 631 times

last updated: 14 Oct '14, 03:04