zoukankan      html  css  js  c++  java
  • 【POJ 2230】 Watchcow

    【题目链接】

                http://poj.org/problem?id=2230

    【算法】

                 欧拉回路

    【代码】

               

    #include <algorithm>
    #include <bitset>
    #include <cctype>
    #include <cerrno>
    #include <clocale>
    #include <cmath>
    #include <complex>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <ctime>
    #include <deque>
    #include <exception>
    #include <fstream>
    #include <functional>
    #include <limits>
    #include <list>
    #include <map>
    #include <iomanip>
    #include <ios>
    #include <iosfwd>
    #include <iostream>
    #include <istream>
    #include <ostream>
    #include <queue>
    #include <set>
    #include <sstream>
    #include <stdexcept>
    #include <streambuf>
    #include <string>
    #include <utility>
    #include <vector>
    #include <cwchar>
    #include <cwctype>
    #include <stack>
    #include <limits.h>
    using namespace std;
    #define MAXN 10010
    #define MAXM 50010
    
    struct Edge
    {
            int to,nxt;
    } e[MAXM<<1];
    int i,n,m,u,v,tot;
    bool vis[MAXM<<1];
    int head[MAXN];
    
    inline void add(int u,int v)
    {
            tot++;
            e[tot] = (Edge){v,head[u]};
            head[u] = tot;        
    }
    inline void dfs(int u)
    {
            int i;
            for (i = head[u]; i; i = e[i].nxt)
            {
                    if (!vis[i])
                    {
                            vis[i] = true;
                            dfs(e[i].to);        
                    }
            }        
            printf("%d
    ",u);
    }
    
    int main() 
    {
            
            scanf("%d%d",&n,&m);
            for (i = 1; i <= m; i++)
            {
                    scanf("%d%d",&u,&v);
                    add(u,v);
                    add(v,u);            
            }
            dfs(1);
            
            return 0;
        
    }
  • 相关阅读:
    最精简的django程序
    spring+mongo
    从零搭建mongo分片集群的简洁方法
    java对redis的基本操作
    awk输出指定列
    sed输出指定行
    Bash的循环结构(for和while)
    用ffmpeg切割音频文件
    Python判断字符串是否全是字母或数字
    Python函数: any()和all()的用法
  • 原文地址:https://www.cnblogs.com/evenbao/p/9267939.html
Copyright © 2011-2022 走看看