Untitled

 avatar
unknown
c_cpp
3 years ago
909 B
8
Indexable
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  
  ll n; cin >> n;
  vector<vector<ll>> xy(n);

  for (ll i = 0; i < n; ++i) {
    ll x, y; cin >> x >> y;
    xy[i].push_back(x);
    xy[i].push_back(y);
  }



  string s; cin >> s;
  for (ll i = 0; i < n; ++i) {
    if (s[i] == 'R') xy[i].push_back(1);
    if (s[i] == 'L') xy[i].push_back(-1);
  }

  sort(xy.begin(), xy.end());
  sort(xy.begin(), xy.end(), [](vector<ll> &alpha, vector<ll> &beta) {return alpha[1] < beta[1];});

  debug(xy);

  ll yes = 0;

  long long last_R_index = -1;

  if (xy[0][2] == 1) last_R_index = 0;

  for (ll i = 1; i < n; ++i) {

    if (xy[i][2] == -1)
    {
      if (last_R_index >= 0 and xy[last_R_index][1] == xy[i][1])
      {
        yes = true;
      }
    }
    else if (xy[i][2] == 1)
    {
      last_R_index = i;
    }

  }
  if (yes) cout << "Yes\n";
  else cout << "No\n";
}
Editor is loading...