fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. const int MaxN=2e5;
  5. const int MaxA=1e9;
  6. struct NODE{
  7. int x, y, d;
  8. NODE(int x=0,int y=0,int d=0):x(x),y(y),d(d){}
  9. bool operator<(const NODE rhs)const{
  10. return (y!=rhs.y)? y<rhs.y: x<rhs.x; }
  11. } node[MaxN];
  12.  
  13. int func(int s,int e){
  14. int n;
  15. for(n=s; n<e && node[n].d==0; n+=1);
  16. if( n==e ) // 全部向左
  17. return 0;
  18. for(n+=1; n<e && node[n].d; n+=1);
  19. return n<e;
  20. }
  21.  
  22. int main(){
  23. int N;
  24. string S;
  25.  
  26. cin>>N;
  27. for(int n=0; n<N; n+=1)
  28. cin>>node[n].x>>node[n].y;
  29. cin>>S;
  30. for(int n=0; n<N; n+=1)
  31. node[n].d= S[n]=='R';
  32.  
  33. sort(node,node+N);
  34. for(int e,s=0; s<N; s=e){
  35. for(e=s+1; e<N && node[s].y==node[e].y; e++);
  36. // 檢查範圍內的點(Y座標相同)
  37. if( func(s,e) ){
  38. cout<<"Yes";
  39. return 0;
  40. }
  41. }
  42. cout<<"No";
  43. }
  44.  
  45.  
Success #stdin #stdout 0.01s 5868KB
stdin
3
2 3
1 1
4 1
RRL
stdout
Yes