#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int p[N];
int find(int x)
{
if(p[x] != x) p[x] = find(p[x]);
return p[x];
}
int main()
{
int n, m, k;
cin >> n >> m >> k;
for(int i = 1; i <= n; ++ i)
p[i] = i;
map<pair<int,int>,int> hash;
for(int i = 1; i <= m; ++ i)
{
int a, b, r;
cin >> a >> b >> r;
if(r == 1)
p[find(a)] = find(b);
else
{
hash[{a,b}] = r;
hash[{b,a}] = r;
}
}
for(int i = 1; i <= k; ++ i)
{
int x, y;
cin >> x >> y;
bool didui = (hash[{x,y}] == -1);
bool friends = (find(x) == find(y));
if(!didui && friends) cout << "No problem\n";
else if(!didui && !friends) cout << "OK\n";
else if(didui && friends) cout << "OK but...\n";
else cout << "No way\n";
}
return 0;
}
标签:25,hash,didui,int,010,L2,find
From: https://www.cnblogs.com/Frodnx/p/18387461