#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#define f first
#define s second
using namespace std;
pair <char, int>a[100002];
void solve() {
int n;
cin >> n;
cin >> a[0].f >> a[0].s;
for (int i = 1; i < n; i++) {
cin >> a[i].f >> a[i].s;
}
if (a[0].f == '*' || a[n - 1].f == '*') {
cout << "NO";
return;
}
for (int i = 1; i < n - 1; i++) {
if (a[i].f == '#') {
bool check = true;
for (int j = i + 1; j < i + 3; j++) {
if (a[j].s - a[i].s > 2) {
cout << "NO";
return;
}
if (a[j].f == '#') {
check = false;
i = j - 1;
break;
}
}
if (check) {
cout << "NO";
return;
}
}
}
cout << "YES";
}
int main() {
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
Copy