Plz tell me this approach is correct or not
#include<iostream>
#include<string>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
string s;
cin>>s;
int len = s.length();
bool res=false;
for(int i=0;i<len;i++)
{
if((s[i] == 'P' && s[i+1] == 'C' && s[i+2] == 'M') || (s[i] == 'C' && s[i+1] == 'P' && s[i+2] == 'M') ||
(s[i] == 'M' && s[i+1] == 'C' && s[i+2] == 'P') || (s[i] == 'P' && s[i+1] == 'M' && s[i+2] == 'C') || (s[i] == 'C' && s[i+1] == 'M' && s[i+2] == 'P') || (s[i] == 'M' && s[i+1] == 'P' && s[i+2] == 'C') )
{
res = true;
}
}
if(res)
{
cout<<"YES"<<endl;
}
else
{
cout<<"NO"<<endl;
}
}
return 0;
}