Task 17-20 WA
#include<bits/stdc++.h>
using namespace std;
const int maxn=100001;
int n,m,q,tot,head[maxn];
struct edge{
int v,next;
}e[maxn];
struct node{
int odd,even;
}f[maxn];
void add_edge(int u,int v)
{
tot++;
e[tot].v=v;
e[tot].next=head[u];
head[u]=tot;
}
void SPFA()
{
for(int i=1;i<=n;i++) f[i].odd=0x3f,f[i].even=0x3f;
f[1].even=0;
queue<int>q;
q.push(1);
while(!q.empty())
{
int u=q.front();
q.pop();
for(int i=head[u];i;i=e[i].next)
{
int v=e[i].v,x=f[v].odd,y=f[v].even;
f[v].odd=min(f[v].odd,f[u].even+1);
f[v].even=min(f[v].even,f[u].odd+1);
if(f[v].odd!=x||f[v].even!=y) q.push(v);
}
}
}
int main()
{
scanf("%d%d%d",&n,&m,&q);
for(int i=1;i<=m;i++)
{
int u,v;
scanf("%d%d",&u,&v);
add_edge(u,v);
add_edge(v,u);
}
SPFA();
for(int i=1;i<=q;i++)
{
int a,L;
scanf("%d%d",&a,&L);
if(L%2==0&&f[a].even<=L) printf("Yes\n");
else if(L%2!=0&&f[a].odd<=L) printf("Yes\n");
else printf("No\n");
}
return 0;
}