This is the question I am talking about — 1948 C : Arrow Path I have written an easier solution only using if and while loop. Check this out if someone is stuck at this question
**HERE WE GO**
#include <vector>
using namespace std;
int main(){
int t;
char temp;
int take;
cin>>t;
for(int test=0;test<t;test++){
int n;
cin>>n;
string row1;
cin>>row1;
string row2;
cin>>row2;
int i=0;
int row=1;
int nmove=0;
int flag=true;
do{
if(row==1){
if(row1[i+1]=='<'){
if(row2[i]=='<'){
//cout<<i<<endl;
cout<<"NO"<<endl;
flag = false;
break;
}
row = 2;
i=i+1;
nmove++;
}
else{
i=i+2;
nmove=0;
}
}
else{
if(row2[i+1]=='<'&&i!=n-2){
if(row1[i]=='<'){
//cout<<i<<endl;
cout<<"NO"<<endl;
flag = false;
break;
}
row = 1;
i=i+1;
nmove++;
}
else{
i=i+2;
nmove=0;
}
}
if(nmove>=2){
//cout<<i<<endl;
cout<<"NO"<<endl;
flag = false;
break;
}
}while(i<=n-2);
if(flag){
cout<<"YES"<<endl;
}
}
}
Sorry for that, I misunderstood the question. I have got it cleared and updated the blog.
Even I did it easily.I guess our approach is similar just that you wrote a bit too much code
void solve(){ int n; cin>>n; string s1,s2; cin>>s1>>s2;
}
good job!guy