Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=1005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int H,W,N,x0,y0,x1,y1,x2,y2;
string S,T;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>H>>W>>N>>x0>>y0>>S>>T;
	x1=1;x2=H;y1=1;y2=W;
	DEC(i,N-1,0){
		if(T[i]=='D')x1--;
		if(T[i]=='U')x2++;
		if(T[i]=='L')y2++;
		if(T[i]=='R')y1--;
		x1=max(x1,1);
		x2=min(x2,H);
		y1=max(y1,1);
		y2=min(y2,W);
		if(S[i]=='U')x1++;
		if(S[i]=='D')x2--;
		if(S[i]=='R')y2--;
		if(S[i]=='L')y1++;
		if(x1>x2||y1>y2){
			cout<<"NO\n";
			return 0;
		}
		x1=max(x1,1);
		x2=min(x2,H);
		y1=max(y1,1);
		y2=min(y2,W);
	}
	if(x1<=x0&&x0<=x2&&y1<=y0&&y0<=y2)cout<<"YES\n";
	else cout<<"NO\n";
}
/*
3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Compiler output:
a.cc:17:14: error: 'int y0' redeclared as different kind of entity
   17 | int H,W,N,x0,y0,x1,y1,x2,y2;
      |              ^~
In file included from /usr/include/features.h:523,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
                 from /usr/include/c++/14/cassert:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33,
                 from a.cc:1:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:256:1: note: previous declaration 'double y0(double)'
  256 | __MATHCALL (y0,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc:17:20: error: 'int y1' redeclared as different kind of entity
   17 | int H,W,N,x0,y0,x1,y1,x2,y2;
      |                    ^~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)'
  257 | __MATHCALL (y1,, (_Mdouble_));
      | ^~~~~~~~~~
a.cc: In function 'int main()':
a.cc:24:25: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept')
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |         ~~~~~~~~~~~~~~~~^~~~
      |                     |     |
      |                     |     double(double) noexcept
      |                     std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  170 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:170:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept'
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  174 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:174:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(short int)y0' to 'short int&'
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  177 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:177:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(short unsigned int)y0' to 'short unsigned int&'
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
  181 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/14/istream:181:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(int)y0' to 'int&'
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  184 |       operator>>(unsigned int& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:184:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(unsigned int)y0' to 'unsigned int&'
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  188 |       operator>>(long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:188:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(long int)y0' to 'long int&'
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  192 |       operator>>(unsigned long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:192:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(long unsigned int)y0' to 'long unsigned int&'
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  199 |       operator>>(long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:199:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(long long int)y0' to 'long long int&'
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  203 |       operator>>(unsigned long long& __n)
      |       ^~~~~~~~
/usr/include/c++/14/istream:203:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(long long unsigned int)y0' to 'long long unsigned int&'
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  328 |       operator>>(void*& __p)
      |       ^~~~~~~~
/usr/include/c++/14/istream:328:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexcept
a.cc:24:27: error: cannot bind rvalue '(void*)y0' to 'void*&'
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
  122 |       operator>>(__istream_type& (*__pf)(__istream_type&))
      |       ^~~~~~~~
/usr/include/c++/14/istream:122:7: note:   conversion of argument 1 would be ill-formed:
a.cc:24:27: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive]
   24 |         cin>>H>>W>>N>>x0>>y0>>S>>T;
      |                           ^~
      |                           |
      |                           double (*)(double) noexce