#include <bits/stdc++.h>
using namespace std;
int n, m, q;
int u[200005], v[200005];
int rmin[200005];
pair<int, int> t[200005];
int cnt_bad = 0;
pair<int, int> par(int x)
{
int s1 = 0;
while (t[x].first != x)
{
s1 += t[x].second;
x = t[x].first;
}
return make_pair(x, s1 % 2);
}
bool viz[200005];
int kkk;
void dfss(int x, int y)
{
viz[x] = true;
if (x == y)
kkk = kk;
else
{
for (auto vecin : g[x])
{
if (!viz[vecin])
{
kk = 1 - kk;
dfs(vecin);
kk = 1 - kk;
}
}
}
}
void join(int x, int y)
{
pair<int,int> p1 = par(x);
pair<int,int> p2 = par(y);
if (p1.first != p2.first)
{
t[p2.first] = make_pair(p1.first, (1 + p1.second + p2.second) % 2);
int dl = t[p2.first].second;
memset(viz, 0, sizeof(viz));
kk = 0;
dfss(p2.first, p1.first);
if (kkk != dl)
assert(false);
}
else
{
if (p1.second == p2.second)
cnt_bad++;
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> n >> m >> q;
for (int i = 1; i <= m; i++)
cin >> u[i] >> v[i], g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
for (int i = 1; i <= n; i++)
t[i] = {i, 0};
rmin[1] = 1;
for (int i = m; i >= 1; i--)
{
join(u[i], v[i]);
if (cnt_bad != 0)
{
rmin[1] = i + 1;
break;
}
}
for (int i = 1; i <= q; i++)
{
int x, y;
cin >> x >> y;
if (y < rmin[x])
cout << "YES\n";
else
cout << "NO\n";
}
return 0;
}
///wtfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
/**
deci teoretic daca bag elementele de la 1 la N, apoi fac two pointers-ul, o sa cam am queue-like undoing pe DSU, pe care tin si ceva de bipartit
**/
Compilation message
Joker.cpp: In function 'void dfss(int, int)':
Joker.cpp:31:15: error: 'kk' was not declared in this scope; did you mean 'kkk'?
31 | kkk = kk;
| ^~
| kkk
Joker.cpp:34:27: error: 'g' was not declared in this scope
34 | for (auto vecin : g[x])
| ^
Joker.cpp:38:17: error: 'kk' was not declared in this scope; did you mean 'kkk'?
38 | kk = 1 - kk;
| ^~
| kkk
Joker.cpp:39:17: error: 'dfs' was not declared in this scope; did you mean 'dfss'?
39 | dfs(vecin);
| ^~~
| dfss
Joker.cpp: In function 'void join(int, int)':
Joker.cpp:55:9: error: 'kk' was not declared in this scope; did you mean 'kkk'?
55 | kk = 0;
| ^~
| kkk
Joker.cpp: In function 'int main()':
Joker.cpp:74:30: error: 'g' was not declared in this scope
74 | cin >> u[i] >> v[i], g[u[i]].push_back(v[i]), g[v[i]].push_back(u[i]);
| ^