-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabc243_c.cpp
More file actions
41 lines (38 loc) · 819 Bytes
/
abc243_c.cpp
File metadata and controls
41 lines (38 loc) · 819 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main(){
int N; cin >> N;
int people[N][2];
for (int i = 0; i < N; i++) cin >> people[i][0] >> people[i][1];
map<int, int> right;
map<int, int> left;
string str; cin >> str;
for (int i = 0; i < N; i++) {
int y = people[i][1];
int x = people[i][0];
if (str[i] == 'L') {
if (left.find(y) == left.end()) {
left[y] = x;
} else {
left[y] = max(left[y], x);
}
} else {
if (right.find(y) == right.end()) {
right[y] = x;
} else {
right[y] = min(right[y], x);
}
}
}
for (auto [y, x] : right) {
if (left.find(y) != left.end() && left[y] >= x) {
cout << "Yes";
return 0;
}
}
cout << "No";
return 0;
}