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. https://www.codechef.com/viewsolution/17563758
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;
}
}
else{
break;//Causes it to break out of loop skipping the return statement.
return false;
}
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.