initial commit
This commit is contained in:
parent
73f1784367
commit
e91f369221
35
1791B Following Directions/1791B.cpp
Normal file
35
1791B Following Directions/1791B.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include<bits/stdc++.h>
|
||||
using namespace std;
|
||||
using ll = long long;
|
||||
|
||||
void solve()
|
||||
{
|
||||
int n,x=0,y=0;
|
||||
cin>>n;
|
||||
string s;
|
||||
cin>>s;
|
||||
for(int i=0;i<s.size(); ++i)
|
||||
{
|
||||
if(s[i]=='U') y++;
|
||||
else if(s[i]=='D') y--;
|
||||
else if (s[i]=='R') x++;
|
||||
else if(s[i]=='L') x--;
|
||||
if(x==1 && y==1)
|
||||
{
|
||||
cout<<"YES"<<endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
cout<<"NO"<<endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
ios_base::sync_with_stdio(false);
|
||||
cin.tie(nullptr);
|
||||
|
||||
int TC = 1;
|
||||
cin >> TC;
|
||||
cin.ignore();
|
||||
while (TC--) solve();
|
||||
}
|
Loading…
Reference in New Issue
Block a user