Can anyone tell whats wrong

#include
#include <string.h>
using namespace std;
int main(){
int t,y=0;
cin>>t;
while(t–){
string s;
getline(cin,s);
for(int i=0;i<=s.length()+1;i++){
y=0;
if((s[i]==‘n’ || s[i]==‘N’ ) && (s[i+1]==‘o’) && (s[i+2]==‘t’)){
cout<<“Real Fancy”<<endl;
y=1;
break;
}
else{
y=-1;

		}
		if(y==-1){
			cout<<"regularly fancy"<<endl;
		}
	}
	
}
return 0;

}
Problem-Contest Page | CodeChef

Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile! :slight_smile:

Also - which Problem are you trying to solve?

Edit:

If it’s this: you need to output:

regularly fancy

instead of

regularly Fancy
2 Likes

Thanks for your feedback:))
Done…
But still desired output not coming

Please link to your latest submission :slight_smile:

1 Like

Yepp
Solution-Error Page | CodeChef

2 Likes

Okayy
https://www.codechef.com/viewsolution/53388857

1 Like

Thanks - several things, here:

Firstly, you’re running into the same issue as this guy when reading in the lines (you have to ignore the rest of the line after you read the number of testcases - you should be able to figure out how from reading the thread.)

Secondly, you’re reading outside the bounds of s:

 for(int i=0;i<=s.length()+1;i++){
   // ... snip ...
            if((s[i]=='n' || s[i]=='N' ) && (s[i+1]=='o') && (s[i+2]=='t')){
2 Likes

Thankyou so much for your help
Solution - Solution: 53396956 | CodeChef
But still I guess I am leaving some test case

Out-of-bounds access on e.g.:

1                
a
2 Likes

Understood thanks with your help:)

1 Like

sir this i just joined codechef today and this is my solution to a question which i tried but it’s not submitting even though working correctly
MY SOLUTION

There might be other problems, but fix this first :slight_smile: