#include <bits/stdc++.h>
#define maxn 120005
#define fi first
#define se second
using namespace std;
using ii = pair<int, int>;
int n, k;
int cl[maxn], timer = 0;
void queryS() {
int u, v;
cin >> u >> v;
cl[max(u, v)] = ++timer;
}
void queryQ() {
int a, d;
cin >> a >> d;
if (a == d) {
cout << "yes\n";
return;
}
if (a == 1) {
cout << (cl[d] == 1e9 ? "no\n" : "yes\n");
return;
}
cout << (cl[a] > cl[d] ? "yes\n" : "no\n");
}
void queryC() {
int x;
cin >> x;
if (x == 1) cout << timer << "\n";
else cout << max(0, timer-cl[x]) + 1 << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> k;
for (int i = 1; i <= n; i++) cl[i] = 1e9;
for (int _ = 1; _ < n+k; _++) {
char type;
cin >> type;
switch (type) {
case 'S' :
queryS();
break;
case 'Q' :
queryQ();
break;
default :
queryC();
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |