判欧拉图两个条件首先联通,其次度全部为欧度。那么就很easy了。
题目:hdoj1878
求一个图中欧拉图的个数。
首先通过连通性求出各个子图,然后求子图中奇数度的个数cnt,cnt/2为欧拉图的个数。若子图没有奇数度,则为一个欧拉回路。
注意这个题目中可能出现孤立点,不算入欧拉图中。
AC代码:
include
include
include
include
include
include
include
include
include
include
include
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 100030;
int cnt[N];
int ans,cou;
vector g[N];
bool ok[N];
void dfs(int x)
{
for(int i=0;i
时间: 2024-12-10 21:41:51