1221
zqrmon
·
·
个人记录
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
cin >> n >> q;
map<int, unordered_set<int>> follows;
for (int i = 0; i < q; ++i) {
int op, a, b;
cin >> op >> a >> b;
if (op == 1) {
follows[a].insert(b);
} else if (op == 2) {
follows[a].erase(b);
if (follows[a].empty()) {
follows.erase(a);
}
} else if (op == 3) {
if (follows[a].count(b) && follows[b].count(a)) {
cout << "Yes\n";
} else {
cout << "No\n";
}
}
}
return 0;
}