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 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

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; }

21st Feb 2022, 10:39 AM
I Am Anushka
2 Answers
0
G'day I Am Anushka that seems to be a nice problem to work on. Did you have a question? Have you read the SoloLearn FAQ? You could post a "code bit" instead of that wall of code, you could tag your programming language instead of those useless tags, and you could ask a question... https://www.sololearn.com/discuss/333866/?ref=app
21st Feb 2022, 9:09 PM
HungryTradie
HungryTradie - avatar
0
Sup guyz?
11th Jan 2023, 8:42 AM
DeathDealer007
DeathDealer007 - avatar