题意
给一张n个点m条边的无向图,要求给每条边定向。
要求对于给出的q组限制(u,v),点u都可以到达点v。
询问是否可行。
n,m,q<=200000
分析
对于一个边双连通分量中的点,肯定是让他们能够互相到达是最优的。
那么就先把所有边双缩起来,就变成了一棵树的定向问题。
对于一棵树的定向,我们可以用树上差分来实现。具体看代码。
代码
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=200005;
int n,m,q,cnt,last[N],dfn[N],low[N],top,stack[N],tim,now,bel[N],c[N],tot,dep[N],fa[N][20],f[N],g[N];
bool vis[N],ins[N];
struct edge{
int to,next;}e[N*4];
int read()
{
int x=0,f=1;char ch=getchar();
while (ch<'0'||ch>'9'){
if(ch=='-')f=-1;ch=getchar();}
while (ch>='0'&&ch<='9'){
x=x*10+ch-'0';ch=getchar();}
return x*f;
}
void addedge(int u,