HEADBOB : Getting wrong answer although working fine in IDE

Here’s the link to the problem - http://www.codechef.com/problems/HEADBOB
Thanks in advance .

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;

int main(){
int t,i,ci,cy,cn,n;
char s[1000];
cin>>t;
while(t--){
	ci=0;cy=0;cn=0;
	cin>>n;
	for(i=0;i<n;i++){
	
	cin>>s[i];
	
	
		
		if(s[i]=='N')
		cn++;
		
		else if(s[i]=='Y')
		cy++;
		
		else if(s[i]=='I')
		ci++;
	}
	if(ci)
	cout<<"INDIAN"<<endl;
	else if(ci==0&&(cn&&cy))
	cout<<"NOT INDIAN"<<endl;
	else if(cy==0&&ci==0)
	cout<<"NOT SURE"<<endl;
	
}
return 0;
}

hey please give right link its not working.

are you using && for logical operator ‘and’ or as a bit-wise?

i am asking this because i am not familiar with c++ so much so please tell so that i can look it at and find what’s wrong because i have basic knowledge in c++ which you have used.

The first problem i see in the code is the method used for inputting the string. you need to give space between characters. Try using gets().
secondly, dropping the condition for N can be done and using instead ((ci || cy) == 0) should work.

Well, you have to input a string( characters without spaces ) but your code will input space separated integers. Better use the string data type.

Eg:

string s;

cin>>s;

Look at my code to understand the logic: http://www.codechef.com/viewsolution/7214260

if you have any doubts related to any of your answers and want to LEARN and SHARE good tricks and concepts in coding.join our coding community and let us all coders rock

link:https://www.facebook.com/codesharing0

anupam_dutta .i suggest you to ask this question in above link.you can see there many are clearing doubts there.

if you have any doubts related to any of your answers and want to LEARN and SHARE good tricks and concepts in coding.join our coding community and let us all coders rock

link:https://www.facebook.com/codesharing0

anupam_dutta .i suggest you to ask this question in above link.you can see there many are clearing doubts there.

Which question?

sorry…if you want to share your question and answer…share this on our communtity page…“LET CODERS ROCK”…

IT MAKES OTHER CODERS SHARE THEIR CONCEPTS AND DOUBTS,ULTIMATELY WE CODERS IMROVE OUR SKILLS

using it as AND operator

@vinay1729 sorry , corrected now