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

×

Please help me in GOODBAD

This Program is giving the correct output in codeBlocks but showing wrong answer in codechef.

Problem Statement https://www.codechef.com/problems/GOODBAD

My Program:-

#include<iostream>
using namespace std;
int main()
{
int T,N,h,K,countC,countS;
string s;
cin>>T;
cout<<endl;
while(T>0){
cin>>N>>K;
cin>>s;
h=s.length();
countC=0;countS=0;
for(int i=0;i<h; i++){
if(isupper(s[i])==1)
countC++;
else countS++;
}
if (countC==K)
cout<<"chef";
else if (countS==K)
cout<<"brother";
else if(K==0){
if(countC==N)
cout<<"brother";
else
cout<<"chef";
}
else if (countS>K &&countC<K)
    cout<<"chef";
    else if (countC>K &&countS<K)
    cout<<"brother";
    else if(countS<K&&countC<K)
cout<<"both";
else cout<<"none";
T--;
}
return 0;
}

asked 12 Jan, 21:19

shubham535's gravatar image

0★shubham535
1
accept rate: 0%

converted to question 12 Jan, 21:42

vijju123's gravatar image

5★vijju123 ♦
11.7k1319

toggle preview
Preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

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

×2,030
×874

question asked: 12 Jan, 21:19

question was seen: 49 times

last updated: 12 Jan, 21:43