#include
using namespace std;
int main(){
int t;
cin>>t;
while(t–){
string s;
cin>>s;
int countg=0, countb=0;
int l= s.size();
for(int i=0;i<l;i++){
if(s[i] == ‘f’ || s[i]==‘r’ || s[i]==‘i’ || s[i]==‘e’ || s[i]==‘z’ || s[i]==‘a’)
countg++;
else
countb++;
if((s[i] == ‘f’ || s[i]==‘r’ || s[i]==‘i’ || s[i]==‘e’ || s[i]==‘z’ || s[i]==‘a’)&&(s[i+1] != ‘f’ && s[i+1]!=‘r’ && s[i+1]!=‘i’ && s[i+1]!=‘e’ && s[i+1]!=‘z’ && s[i+1]!=‘a’)){
cout<<countg;
countg=0;}
if((s[i] != ‘f’ && s[i]!=‘r’ && s[i]!=‘i’ && s[i]!=‘e’ && s[i]!=‘z’ && s[i]!=‘a’)&&(s[i+1] == ‘f’ || s[i+1]==‘r’ || s[i+1]==‘i’ || s[i+1]==‘e’ || s[i+1]==‘z’ || s[i+1]==‘a’)){
cout<<countb;
countb=0;
}
if((i==l-1)&&countg!=0)
cout<<countg;
if((i==l-1)&&countb!=0)
cout<<countb;
}}
return 0;
}
where is the problem with this code. Its giving wrong answer whereas its passing the given test cases.
@riju321 can you please upload a pic of your code as it seems to be difficult to understand your code like this.
Lol! A very big code, with a trivial error!
You aren’t printing a new line after each test case! Check this out!
https://www.codechef.com/submit/complete/19051979
Hope this helps! And do upvote and accept the answer if it helped (I think it did!)