Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* اللهم لا سهل الا ما جعلته سهلا وانت تجعل الحزن ان شأت سهلا */
- #include <bits/stdc++.h>
- #include <iomanip>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- template <class T>
- using ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
- template <typename T = int>
- ostream &operator<<(ostream &out, const vector<T> &v)
- {
- for (const T &x : v)
- out << x << ' ';
- return out;
- }
- template <typename T = int>
- istream &operator>>(istream &in, vector<T> &v)
- {
- for (auto &x : v)
- in >> x;
- return in;
- }
- using namespace __gnu_pbds;
- #define getline(s) getline(cin >> ws, s)
- #define ll long long
- #define sz(s) (int)(s.size())
- const int M = 2 * 1e5 + 5;
- #define HABIBA \
- ios_base::sync_with_stdio(false); \
- cin.tie(0); \
- cout.tie(0);
- #define PI 3.14159
- #define pi 3.141592653589793
- #define ull unsigned long long
- #define all(s) s.begin(), s.end()
- #define fix(x) setprecision(x) << fixed
- #define PB push_back
- #define Mod 1'000'000'007
- #define to_binary(bin) stoll(bin, nullptr, 10)
- #define ceill(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
- #define cin(v) \
- for (auto &i : v) \
- cin >> i
- #define cout(v) \
- for (auto &i : v) \
- cout << i << " ";
- #define Ndigits(n) ((int)log10(n) + 1)
- #define unq(VEC) \
- sort(all(VEC)); \
- VEC.resize(unique(all(VEC)) - VEC.begin());
- using namespace std;
- #define Num_of_Digits(n) ((int)log10(n) + 1)
- #define cin_2d(vec, n, m) \
- for (int i = 0; i < n; i++) \
- for (int j = 0; j < m && cin >> vec[i][j]; j++) \
- ;
- #define cout_2d(vec, n, m) \
- for (int i = 0; i < n; i++, cout << "\n") \
- for (int j = 0; j < m && cout << vec[i][j] << " "; j++) \
- // freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin),
- freopen("output.txt", "w", stdout);
- #endif
- HABIBA
- set < pair < ll , ll >>st;
- st.insert(make_pair(0 , 0));
- ll n; cin >> n;
- string s; cin >> s;
- ll t1 = 0 , t2 = 0;
- for(int i = 0; i < n; i++){
- if(s[i] == 'U')
- t2++;
- if(s[i] == 'D')
- t2--;
- if(s[i] == 'L')
- t1--;
- if(s[i] == 'R')
- t1++;
- ll hbd = sz(st);
- st.insert(make_pair(t1 , t2));
- if(hbd == sz(st))
- return cout << "YES" , 0;
- }
- cout << "NO";
- return 0 ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement