<span style="font-size:18px;">//连通图存在欧拉回路,等价于每个节点的度为偶数
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <vector>
#include <fstream>
#include <string>
int main()
{
ifstream infile;
string filename = "case.txt";
infile.open(filename.c_str());
cin.rdbuf(infile.rdbuf());
vector<int> degree(1001, 0);
int i, j;
int N, M;
while (cin >> N)
{
if (N == 0)
break;
cin >> M;
while (M--)
{
cin >> i >> j;
++degree[i];
++degree[j];
}
bool flag=true;
for (int k = 1; k <= N; ++k)
{
if (degree[k] % 2 != 0 || degree[k] == 0)
{
flag = false;
break;
}
}
if (flag)
cout << 1 << endl;
else
cout << 0 << endl;
degree.assign(1001, 0);
}
return 0;
}</span>
连通图存在欧拉回路,等价于每个节点的度为偶数
最新推荐文章于 2022-08-14 12:29:43 发布