没有见过把map开成数组的
by 星空舞涵 @ 2020-11-24 16:47:06
您写的什么?蒟蒻表示没见过?
by 梦游的小雪球 @ 2020-11-24 16:48:22
map和find函数都有问题
```cpp
#include <bits/stdc++.h>
#include <map>
using namespace std;
int n, m;
map<string, string> fa;
string find(string s) {
if (fa[s] == s) return fa[s];
return fa[s] = find(fa[s]);
}
void merge(string x, string y) {
x = find(x);
y = find(y);
if (x != y) {
fa[y] = x;
}
}
int main() {
cin >> n >> m;
for (int i = 0; i < n; i++) {
string name;
cin >> name;
fa[name] = name;
}
for (int i = 0; i < m; i++) {
string x, y;
cin >> x >> y;
merge(x, y);
}
int k;
cin >> k;
for (int i = 0; i < k; i++) {
string x, y;
cin >> x >> y;
if (find(x) == find(y)) cout << "Yes." << endl;
else cout << "No." << endl;
}
return 0;
}
```
by 星空舞涵 @ 2020-11-24 16:48:30
D
by Cstdio_Rabbit @ 2021-05-10 19:42:23