C++#include<bits/stdc++.h>
using namespace std;
int n,m,q;
int x,y,a,l;
int dis1[100005],dis2[100005];//奇数最短路和偶数最短路
vector<int> g[100005];
struct node{
int x,step;
};
void bfs(){
memset(dis1,0x3f,sizeof dis1);
memset(dis2,0x3f,sizeof dis2);
queue <node> q;//记录步数
q.push({1,0});
while(q.size()){
node f = q.front();
q.pop();
for(int i = 0;i < g[f.x].size();i++){
int v = g[f.x][i];//f.step是从1到v的路径
if((f.step + 1) % 2 == 1){
if(f.step + 1 < dis1[v]) dis1[v] = f.step + 1,q.push({v,f.step + 1});
}else{
if(f.step + 1 < dis2[v]) dis2[v] = f.step + 1,q.push({v,f.step + 1});
}
}
}
}
int main(){
cin >> n >> m >> q;
for(int i = 1;i <= m;i++){
cin >> x >> y;
g[x].push_back(y);
g[y].push_back(x);
}
bfs();
while(q--){
cin >> a >> l;
bool f = 0;
if(l % 2 == 1){
if(dis1[a] > l) cout << "No";
else cout << "Yes";
}else{
if(dis2[a] > l) cout << "No";
else cout << "Yes";
}
cout << '\n';
}
return 0;
}