为什么#7错了呢?求助!
查看原帖
为什么#7错了呢?求助!
261262
WaltVBAlston楼主2020/4/27 16:38

RT,第七个点总是过不去,然后就会爆零,极其难受,还下载不了数据,各位大佬能帮忙看下嘛?

(为了保证大家的观看体验,我改了个马蜂)

#include <cstdio>
#define ll long long
#define maxn1 2000005
#define maxn2 10000005
using namespace std; 
ll u[maxn2],v[maxn2],now[maxn1],before[maxn2],dfn[maxn1],low[maxn1],n,m,deep=0,a,b;
bool is[maxn1];
inline ll min(ll x, ll y)
{
	return x < y ? x : y;
}
void tarjan(ll x)
{
	dfn[x] = low[x] = ++deep;
	for(ll i = now[x]; i != -1; i = before[i]){
		if(!dfn[v[i]]){
			tarjan(v[i]);
			low[x] = min(low[x], low[v[i]]);
			if(low[v[i]] >= dfn[x] && x!=a && dfn[b] >= dfn[x])
				is[x] = true;
		} 
		else
			low[x] = min(low[x], dfn[v[i]]);
	}
	return;
}
int main(){
	scanf("%lld", &n);
	m = 0;
	for(ll i = 1; i <= n; i++){
		now[i] = -1;
		dfn[i] = low[i] = 0;
	}
	while(1){
		m++;
		scanf("%lld%lld", &u[m], &v[m]);
		if(u[m] == 0 || v[m] == 0)
		{
			break;
		}
		before[m] = now[u[m]];
		now[u[m]] = m;
	}
	for(ll i = m + 1; i <= 2*m; i++){
		u[i] = v[i - m];
		v[i] = u[i - m];
		before[i] = now[u[i]];
		now[u[i]] = i;
	}
	scanf("%lld%lld", &a, &b);
	tarjan(a);
	for(ll i = 1; i <= n; i++){
		if(is[i]){
			printf("%lld", i);
			return 0;
		}
	}
	puts("No solution");
	return 0;
}
2020/4/27 16:38
加载中...