#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep1(i, n) for (int i = 1; i < (int)(n+1); i++) #define repn(i,a,b) for (int i = (int)(a) ; i < (int)(b+1); i++) #define repv(i, n) for (int i = (int)(n-1); i >= 0; i--) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) ((int)(x).size()) #define cauto const auto& #define bit(n) (1LL<<(n)) #define uni(v) v.erase( unique(v.begin(), v.end()), v.end() ); using ll = long long; #ifdef LOCAL #include #define debug(...) debug::multi_print(#__VA_ARGS__, __VA_ARGS__) #else #define debug(...) (static_cast(0)) #endif struct dsu { public: dsu() : _n(0) {} dsu(int n) : _n(n), parent_or_size(n, -1) {} int merge(int a, int b) { assert(0 <= a && a < _n); assert(0 <= b && b < _n); int x = leader(a), y = leader(b); if (x == y) return x; if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y); parent_or_size[x] += parent_or_size[y]; parent_or_size[y] = x; return x; } bool same(int a, int b) { assert(0 <= a && a < _n); assert(0 <= b && b < _n); return leader(a) == leader(b); } int leader(int a) { assert(0 <= a && a < _n); if (parent_or_size[a] < 0) return a; return parent_or_size[a] = leader(parent_or_size[a]); } int size(int a) { assert(0 <= a && a < _n); return -parent_or_size[leader(a)]; } private: int _n; std::vector parent_or_size; }; struct Edge { int to; }; using Graph = vector>; using P = pair; struct LowLink { const Graph &G; vector used, ord, low; vector aps; vector

bridges; LowLink(const Graph &G_) : G(G_) { used.assign(G.size(), 0); ord.assign(G.size(), 0); low.assign(G.size(), 0); int k = 0; for (int i = 0; i < (int)G.size(); i++) { if (!used[i]) k = dfs(i, k, -1); } sort(aps.begin(), aps.end()); sort(bridges.begin(), bridges.end()); } int dfs(int id, int k, int par) { used[id] = true; ord[id] = k++; low[id] = ord[id]; bool is_aps = false; int count = 0; for (auto &e : G[id]) { if (!used[e.to]) { count++; k = dfs(e.to, k, id); low[id] = min(low[id], low[e.to]); if (par != -1 && ord[id] <= low[e.to]) is_aps = true; if (ord[id] < low[e.to]) bridges.emplace_back(min(id, e.to), max(id, e.to)); } else if (e.to != par) { low[id] = min(low[id], ord[e.to]); } } if (par == -1 && count >= 2) is_aps = true; if (is_aps) aps.push_back(id); return k; } }; int main(){ int n,m,q; cin >> n >> m >> q; Graph G(n); rep(i,m){ int a,b; cin >> a >> b; a--;b--; Edge e; e.to = b; G[a].push_back(e); e.to = a; G[b].push_back(e); } LowLink lowlink(G); debug(lowlink.bridges); debug(lowlink.aps); vector

ans = lowlink.bridges; dsu ds(n); for(auto p : ans){ ds.merge(p.first,p.second); } rep(i,q){ int c,d; cin >> c >> d; c--;d--; if(ds.same(c,d)) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }