Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include <iostream>#include <vector>#include <stack>#include <cassert>#include <algorithm>using namespace std;struct node {int label;vector<node*> neighbors;node(int i) : label(i) {};};void dfs(vector<int>& path, node* u) {while (!u->neighbors.empty()) {node* v = u->neighbors[u->neighbors.size() - 1];u->neighbors.pop_back();v->neighbors.erase(find(v->neighbors.begin(), v->neighbors.end(), u));dfs(path, v);}path.push_back(u->label);return;}int main() {int N, M, i, j;cin >> N >> M;assert(N >= 1 && N <= 1000);assert(M >= 1 && M <= 5000);vector<node*> graph;