#include<bits/stdc++.h>
using namespace std;
int f[5010];
int find(int x)
{
if(f[x]!=x) return f[x] = find(f[x]);
return x;
}
int main()
{
int n,m,p;
cin>>n>>m>>p;
for(int i = 1; i <= n; i++) f[i] = i;
while(m--)
{
int x,y;
cin>>x>>y;
f[find(x)] = find(y);
}
while(p--)
{
int x,y;
cin>>x>>y;
if(find(x) == find(y))
printf("Yes\n");
else
printf("No\n");
}
}
亲戚
最新推荐文章于 2024-08-10 15:16:13 发布