编译出错QAQ悬关
  • 板块灌水区
  • 楼主WZWZWZWY
  • 当前回复5
  • 已保存回复5
  • 发布时间2023/6/15 18:42
  • 上次更新2023/10/23 13:05:59
查看原帖
编译出错QAQ悬关
704668
WZWZWZWY楼主2023/6/15 18:42
#include <iostream>
#include <vector>
using namespace std;
bool t[100005],stop;//是否在某个环里 
int n,m,x,y,sums;
vector <vector<int> > a[100005];
void dfs(int want,int dq){
	if (dq == want || t[dq]){
		stop = 1;
		return;
	}
	for (int i = 0; i < a[dq].size(); i++){
		t[a[dq][i]] = 1;
		dfs(want,a[dq][i]);
		if (stop) return;
		t[a[dq][i]] = 0;
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i = 1; i <= m; i++){
		scanf("%d%d",&x,&y);
		a[x].push_back(y);
		a[y].push_back(x);
	}
	for (int i = 1; i <= n; i++){
		stop = 0;
		dfs(i);
	}
	for (int i = 1; i <= n; i++) if (t[i]) sums++;
	printf("%d",sums);
}

rt,为什么呢QAQ

2023/6/15 18:42
加载中...