# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1224435 | sokratisi | Inside information (BOI21_servers) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
int n, q, a, b;
int hasleft[125000], hasright[125000];
char c;
int main() {
scanf("%d%d", &n, &q);
for (int i = 0; i < n + q - 1; i++) {
scanf("%d", &c); scanf("%d", &c);
if (c == 'S') {
scanf("%d%d", &a, &b);
if (a > b) swap(a, b); // so a < b
toright[a] = toright[b] + 1;
toleft[b] = toleft[a] + 1;
}
if (c == 'Q') {
scanf("%d%d", &a, &b); // does a store b
if (a < b) {
if (toright[a] >= b - a) {
printf("yes\n");
}
else {
printf("no\n");
}
}
else {
if (toleft[a] >= a - b) {
printf("yes\n");
}
else {
printf("no\n");
}
}
}
}
return 0;
}