奇怪的CE求助
  • 板块灌水区
  • 楼主eigw22h619
  • 当前回复8
  • 已保存回复8
  • 发布时间2022/7/6 17:03
  • 上次更新2023/10/27 21:43:01
查看原帖
奇怪的CE求助
295864
eigw22h619楼主2022/7/6 17:03

源代码:

#include<bits/stdc++.h>
using namespace std;
#define N 2001
struct E{int v,n;E(){}}e[50001];int h[N],$;
inline void add(const int u,const int v)
{
	e[++$].v=v;e[$].n=h[u];h[u]=$;
	e[++$].v=u;e[$].n=h[v];h[v]=$;
}
int mc[N];
bool dfs(const int p)
{
	for(int&i=h[p];i;i=e[i].n)
	if(!mc[e[i].v]||dfs(mc[e[i].v])){mc[e[i].v]=p;mc[p]=e[i].v;i=e[i].n;return true;}
	return false;
}
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	//freopen(".in","r",stdin);
	int n,m,u,v;cin>>n>>m;
	while(m --> 0){cin>>u>>v;add(u,v);}
	int s=0;
	for(int i=1;i<=n;++i)s+=(!mc[i]&&dfs(i));
	cout<<s;
	return 0;
}

本地编译:失败

洛谷编译:通过

2022/7/6 17:03
加载中...