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

×

BUy1 Get1 . Can somebody review my code.

My code runs within time produces desired results uses the obvious logic but still i am getting wrong answer!! please could someone help me with my following code:- http://www.codechef.com/viewsolution/4896723

asked 28 Sep '14, 09:47

mansigupta19's gravatar image

1★mansigupta19
431419
accept rate: 0%


here is your AC code with slight changes

http://www.codechef.com/viewsolution/4919968

link

answered 28 Sep '14, 15:58

anshkhanna7's gravatar image

4★anshkhanna7
1933927
accept rate: 23%

Thanks dude! I would have never figured out that the writing style of if conditions was causing the problem. Could you please also explain why was 97<=*c<=122 was resulting in a WA?

(28 Sep '14, 16:22) mansigupta191★

this does not work because only the first part of condition is taken care of (ie 97<=c) the limiting condition is neglected ie(c<=122)

you can try it yourself

(28 Sep '14, 16:38) anshkhanna74★

You shouldn't consider cases differently

link

answered 28 Sep '14, 11:17

legend_killer's gravatar image

4★legend_killer
215
accept rate: 0%

so a wrong answer is given if a code produces correct output but uses a different approach which is accepted? coz this is happening with me in many problems, logic is exactly as that of accepted code, only method is different :(

link

answered 28 Sep '14, 14:42

mansigupta19's gravatar image

1★mansigupta19
431419
accept rate: 0%

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:

×354

question asked: 28 Sep '14, 09:47

question was seen: 639 times

last updated: 28 Sep '14, 16:38