PCM Dilemma: PCM

                     

Problem link: https://www.codechef.com/CU1AP0005/problems/PCM

Problem code: PCM

After mastering the art of Coding , Chef has decided to master Physics(P) , Chemistry(C) and Maths(M). Luckily he has three sisters where each sister is known to be master of exactly one subject. 
Now you are given a string of size 3 where character at index 1 denotes the subject known to sister I, character at index 2 denotes the subject known to sister II and character at index 3 denotes the subject known to sister III. You have to answer with either “YES” if chef can master “PCM” from his sisters or “NO” if he cannot.

Note
String will only contain characters from the set { P , C , M }.

Solution:

#include<bits/stdc++.h>
#define ll long long int 
using namespace std;

int main()
{
    ll t;
    string s;
    cin>>t;
    while(t--)
    {
        ll size;
        cin>>s;
        size= s.size();
        ll p=0;
        ll c=0;
        ll m=0;
        for(ll i=0;i<size;i++){
            if(s[i] == 'P'){
                p++;
            }
            else if(s[i]== 'C'){
                c++;
            }
            else if(s[i]=='M'){
                m++;
            }
        
        }

        if(p==1 && c==1 && m==1){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }
        
    }
    
}