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


Please help me in TWSTR

I am trying to solve remember the recipe problem.

although i have written my codes and tested it on PC ,here it is giving WA.I have checked that whether my data types are correct or not.As per me they are correct.I think my solution is doing way more computation than required(this is my guess) .Plz check my code and help me so i could submit it correctly.This is my solution.

asked 28 Feb '18, 12:26

jshobhit's gravatar image

accept rate: 0%

converted to question 28 Feb '18, 15:49

vijju123's gravatar image

5★vijju123 ♦♦

Your is_Word() function is wrong. It is returning true even for strings which are not. Try running your code in Codechef IDE, its printing fish with pepper for all queries in sample input.

Basically the problem is here-

if(input[i] == word[i]) {
            if(i==input.length()-1) {
                return true;
            break;//Causes it to break out of loop skipping the return statement.
            return false;

answered 28 Feb '18, 16:00

vijju123's gravatar image

5★vijju123 ♦♦
accept rate: 18%


answered 28 Feb '18, 19:39

jshobhit's gravatar image

accept rate: 0%

hey. as you said i tried running my codes on codechef ide. And yes it is giving wrong answer,i don't know why , while running on my pc it is giving correct answer.What could be the reason,i mean how one code which running fine in my pc is giving wrong answer here.


answered 28 Feb '18, 19:45

jshobhit's gravatar image

accept rate: 0%

That means your code runs on undefined behaviour for some inputs. Happens due to array-out-of-bounds exception etc. Eg, in your isWord function,

for(int i=0;i<input.length();i++) { if(input[i] == word[i]) {

What if length of word is less than length of input? :)

(28 Feb '18, 19:51) vijju123 ♦♦5★

NEED HELP GUYS sorry i m posting it here but i don't have that much point to post a question

a recent ICL2018 a queston called MATRIX GAME was there can anyone help me with that i can't find what i did wrong in my code. Please guyss Please....

Here's my code link :

it's giving me wrong answer... ............


answered 28 Feb '18, 21:19

keshav_'s gravatar image

accept rate: 0%

edited 28 Feb '18, 21:24

Very silly error.

Input 1 1 1 0 Your Output Cyborg Expected Output Draw

Similar if matrix is all 0s.

(28 Feb '18, 21:30) vijju123 ♦♦5★

Thank you!! I haven't considered the case that it can be '0'. Thanks, @vijju123

(01 Mar '18, 09:03) keshav_4★
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 28 Feb '18, 12:26

question was seen: 225 times

last updated: 01 Mar '18, 09:03