We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c4d26c commit b78974eCopy full SHA for b78974e
1791B - Following Directions.cpp
@@ -0,0 +1,40 @@
1
+// ॐ नमः शिवाय
2
+#include<bits/stdc++.h>
3
+using namespace std;
4
+#define ll long long
5
+
6
+// Code Written By: Vikash Patel
7
+// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8
9
+bool check(string s, int n)
10
+{
11
+ int x=0,y=0;
12
+ for(int i=0;i<n;i++)
13
+ {
14
+ if(s[i]=='U')
15
+ y++;
16
+ if(s[i]=='D')
17
+ y--;
18
+ if(s[i]=='R')
19
+ x++;
20
+ if(s[i]=='L')
21
+ x--;
22
+ if(x==1 && y==1)
23
+ return 1;
24
+ }
25
+ return 0;
26
+}
27
+int main()
28
29
+ int t;
30
+ cin>>t;
31
+ while(t--)
32
33
+ int n;
34
+ cin>>n;
35
+ string s;
36
+ cin>>s;
37
+ cout<<((check(s,n))?"YES":"NO")<<endl;
38
39
40
0 commit comments