标签:algo ble bre == ora 欧拉路径 题目 pac back
#include<iostream> #include<vector> #include<algorithm> #include<string> #include<stdio.h> using namespace std; #define maxLen 1001 class node{ public: vector<int> list; //用邻接表来存储图 int count(){ return list.size(); } void push(int index){ list.push_back(index); } int pop(){ int index = list.back(); list.pop_back(); return index; } void clear(){ list.clear(); } }; int main(){ int N; int M; vector<int> result; node vertex[maxLen+1];//从下表1开始 while (true){ cin >> N; if (N == 0){ break; } else{ cin >> M; for (int i = 0; i < M; ++i){ int v1, v2; cin >> v1 >> v2; vertex[v1].push(v2); vertex[v2].push(v1); } int j; for (j = 0; j < N; ++j){ if (vertex[j].count() % 2 != 0){ break; } } if (j == N){ result.push_back(1); } else{ result.push_back(0); } } } for (int i = 0; i < result.size(); ++i){ cout << result[i] << endl; } system("pause"); return 0; }
标签:algo ble bre == ora 欧拉路径 题目 pac back
原文地址:http://www.cnblogs.com/codeDog123/p/6668166.html