这个题看着就和图的连通性有关,排除点双,所以就用边双了。所以先进行一次边双缩点。首先不在一个连通块里的显然是无解的,然后再分 \(s\) 和 \(t\) 是否在一个边双里面进行讨论。如果 \(s\) 和 \(t\) 在一个边双里面,这种情况一定是有解的。如果 \(s\) 和 \(t\) 不在一个边双里面,就直接在 \(s\) 到 \(lca\) 的路径上打上向上的标记,在 \(lca\) 到 \(t\) 的路径上打上向下的标记,这里可以使用树上差分,最后看每个点是否只有向上或者向下或者没有标记即可
#include <bits/stdc++.h>
//#define int long long
#define ull unsigned long long
#pragma GCC optimeze(3)
#pragma GCC optimeze(2)
#define PII pair<int, int>
#define pb push_back
#define fi first
#define se second
#define lowbit(x) (x & (-x))
#define inv(x) (qpow(x,mod-2))
#define blong(i) ((i+K-1)/K)
using namespace std;
const int N=2e5+10;
const int M=3e2+5;
const int mod=9901;
double eps=1e-6;
inline int read(){char ch=getchar();bool f=0;int x=0;for(;!isdigit(ch);ch=getchar())if(ch=='-')f=1;for(;isdigit(ch);ch=getchar())x=(x<<1)+(x<<3)+(ch^48);if(f==1)x=-x;return x;
}
int n,m,k,bj1[N],bj2[N],u[N],v[N],dep[N],fa[N][20],bj[N],dfn[N],low[N],dfc,edc[N],cnt;
vector<int>G[N],G2[N];
void dfs(int t){bj[t]=dfc;for(auto to:G2[t]){if(to==fa[t][0])continue;fa[to][0]=t,dep[to]=dep[t]+1;dfs(to);}
}
stack<int>S;
void tj(int t,int fr){dfn[t]=low[t]=++dfc;S.push(t);for(auto ed:G[t]){int to=u[ed]+v[ed]-t;if(!dfn[to]){tj(to,ed);low[t]=min(low[t],low[to]);}else if(fr!=ed)low[t]=min(low[t],dfn[to]);}if(low[t]==dfn[t]){cnt++;while(S.top()!=t)edc[S.top()]=cnt,S.pop();edc[S.top()]=cnt,S.pop();}
}
int lca(int x,int y){if(dep[x]<dep[y])swap(x,y);for(int i=19;i>=0;i--){if(dep[fa[x][i]]>=dep[y])x=fa[x][i];}if(x==y)return x;for(int i=19;i>=0;i--){if(fa[x][i]!=fa[y][i])x=fa[x][i],y=fa[y][i];} return fa[x][0];
}
void dfs2(int t){bj[t]=1;for(auto to:G2[t]){if(bj[to])continue;dfs2(to);bj1[t]+=bj1[to],bj2[t]+=bj2[to];}if(bj1[t]&&bj2[t]){cout<<"No";exit(0);}
}
signed main(){ ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);cin>>n>>m>>k;for(int i=1;i<=m;i++){cin>>u[i]>>v[i];G[u[i]].pb(i),G[v[i]].pb(i); }for(int i=1;i<=n;i++){if(!dfn[i])tj(i,0);}for(int i=1;i<=n;i++){for(auto ed:G[i]){int to=u[ed]+v[ed]-i;if(edc[to]!=edc[i])G2[edc[i]].pb(edc[to]);} }dfc=0;for(int i=1;i<=cnt;i++){if(!bj[i])dfc++,dep[i]=1,dfs(i); }for(int j=1;j<=19;j++){for(int i=1;i<=cnt;i++){fa[i][j]=fa[fa[i][j-1]][j-1];}}while(k--){int s,t;cin>>s>>t;s=edc[s],t=edc[t];if(bj[s]!=bj[t]){cout<<"No";return 0;}if(s==t)continue;int l=lca(s,t);bj1[s]++,bj1[l]--,bj2[t]++,bj2[l]--;}memset(bj,0,sizeof bj);for(int i=1;i<=cnt;i++){if(!bj[i])dfs2(i);}cout<<"Yes";return 0;
}