-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrowPath.cpp
62 lines (53 loc) · 1.24 KB
/
ArrowPath.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--){
int n;
cin>>n;
long long a[2][n];
string s1,s2;
cin>>s1>>s2;
for (int i = 0; i < n; i++)
{
a[0][i]=s1[i];
}
for (int i = 0; i < n; i++)
{
a[1][i]=s2[i];
}
if(n==2){
cout<<"YES"<<endl;
}
else if(n==3){
}
else if(s2[n-2]=='<'){
cout<<"NO"<<endl;
}
else{
bool ok = true;
int i=1,j=n-2;
while(j>0){
if(a[(i+1)%2][j-1]=='>'){
i=(i+1)%2;
j--;
}
else if(a[i][j-2]=='>' && j>=2){
j-=2;
}
else{
ok=false;
break;
}
}
if(ok){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
}
}