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

×

Please help me in MANYCHEF

https://www.codechef.com/problems/MANYCHEF <--- problem

https://www.codechef.com/viewsolution/17519681 <--my solution

Getting WA, i spent like 2 hours maybe even 3, I am unimaginably slow!

asked 24 Feb '18, 16:36

llgokull_007's gravatar image

2★llgokull_007
144
accept rate: 0%

converted to question 24 Feb '18, 21:53

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066


I cannot tell what is wrong with your code since I code in C++. But you can solve this problem by

iterating over the string from the last and taking 4 characters as long as we can do this and check whether we can replace it with "CHEF".

if (((s[i-3] == '?' || s[i-3] == 'C') && (s[i-2] == '?' || s[i-2] == 'H') && (s[i-1] == '?' || s[i-1] == 'E') && (s[i] == '?' || s[i] == 'F')) && i >= 3)

else '?' should be replaced by 'A'.

Sorry, If you already know this.

You can refer to editorial : here

link

answered 25 Feb '18, 13:53

dkbbhavya's gravatar image

2★dkbbhavya
563
accept rate: 42%

Thank you for replying, i tried same approach- in the inner for loop inside while. That didn't work!

but surprisingly if i hardcoded that like you said it worked....

:)

thanks a ton!

(25 Feb '18, 14:14) llgokull_0072★
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:

×3,820
×1,070
×643

question asked: 24 Feb '18, 16:36

question was seen: 154 times

last updated: 25 Feb '18, 14:14