Because the snakes come in a procession, and one by one, a valid report would be something like "..H..T…HTH….T.", or "…", or "HT
e <iostream> using namespace std; int main() { int t; cin>>t; for(int i=0;i<t;i++){ int n,count=0; cin>>n; char arr[n+1]; cin>>arr; char newi[n+1]; for(int r=0;r<n+1;r++){ if(arr[r]=='.'){ continue; } else{ newi[count]=arr[r]; count++; } } cout<<count<<endl; newi[count-1]='/0'; int y=0; while(newi[y]!='/0'){ if((y%2)==0){ if(newi[y]=='T'){ cout<<y<<endl<<newi[y]<<endl; cout<<"INVALID"<<endl; break; } } else if ((y%2)==1){ if(newi[y]=='H'){ cout<<newi[y]<<endl<<y<<endl; cout<<"INVALID"<<endl; break; } } else if(y==count-1){ cout<<y<<endl<<newi[y]<<endl; cout<<"VALID"<<endl; } y++; } } return 0; }