rqnoj-379
来源:互联网 发布:2k16樱木花道脸部数据 编辑:程序博客网 时间:2024/05/18 00:48
#include <iostream>#include <cstdio>#include <string>#include <map>using namespace std;int father[2008];int fatherind_Set(int x){ if(father[x] != x) father[x] = fatherind_Set(father[x]); return father[x];}void Union(int x, int y){ x = fatherind_Set(x); y = fatherind_Set(y);if(x != y)father[x]=y;}int main(){ map<string,int> map; int n, m, p,i; cin >> n >> m >> p; string a,b; for(i = 1; i <= n; i++) { cin >> a; map[a] = i; father[i] = i; } for(i = 1; i <= m; i++) { cin >> a >> b; Union(map[a],map[b]); } for(i = 1; i <= p; i++) { cin >> a >> b; if(fatherind_Set(map[a]) == fatherind_Set(map[b])) cout << "safe\n"; else cout << "cc cry\n"; } return 0;}
- rqnoj-379
- RQNOJ 379 约会计划[并查集]
- rqnoj-332 & rqnoj-53
- RQNOJ 164
- RQNOJ 311
- RQNOJ 34
- 决斗 RQNOJ
- rqnoj-153
- rqnoj-394
- rqnoj-3
- rqnoj-12
- rqnoj-93
- rqnoj-4
- rqnoj-1
- rqnoj-2
- rqnoj-20
- rqnoj-15
- rqnoj-16
- rqnoj-159
- rqnoj-51
- rqnoj-133
- rqnoj-114
- rqnoj-53
- rqnoj-379
- 最长公共子序列(LCS, Longest Common Subsequence), POJ 1458
- rqnoj-343
- PE重定位表
- rqnoj-331
- rqnoj-28
- hdu-1181
- hdu-2553
- hdu-1241