fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define GG ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  4. int n; char arr[4][1000000]; bool res=0;
  5. bool gen(int x,int y)
  6. { bool f1=0,f2=0,f3=0;
  7. if(x>2 || y>n-1 || x<1)
  8. return 0;
  9. if( (x==2 && y==n-1) || (x==2 && y==n-2) || (x==1 && y==n-1) )
  10. return 1;
  11.  
  12. if(arr[x][y+1]=='>')
  13. f1=gen(x,y+2);
  14. if(arr[x+1][y]=='>')
  15. f2=gen(x+1,y+1);
  16. //if(arr[x-1][y]=='>')
  17. //f3=gen(x-1,y+1);
  18.  
  19. return res|=f1|f2;
  20. }
  21.  
  22. int main () { GG;
  23. int t; cin>>t;
  24. while(t--){
  25. cin>>n; res=0;
  26. for(int i=0;i<4;i+=3)
  27. for(int j=0;j<n;j++)
  28. arr[i][j]='/';
  29.  
  30. for(int i=1;i<=2;i++)
  31. for(int j=0;j<n;j++)
  32. cin>>arr[i][j];
  33. //if(gen(1,1)) cout<<"YES\n";
  34. //else cout<<"NO\n";
  35. cout<<gen(1,1)<<" ";
  36.  
  37. }return 0;}
Success #stdin #stdout 0.01s 5540KB
stdin
1
6
><>><<
>>><><

stdout
0