POJ 2230 Watchcow (欧拉回路)

2015-07-20 17:17:59 · 作者: · 浏览: 5

题目地址:POJ 2230

最普通的欧拉回路。边不重复记录点。不多说。

代码如下:

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
         #include 
         
           #include 
          
            using namespace std; #define LL long long #define pi acos(-1.0) const int mod=1e9+7; const int INF=0x3f3f3f3f; const double eqs=1e-9; int head[11000], cnt, vis[120000], path[120000], tot; struct node { int u, v, id, next; }edge[120000]; void add(int u, int v, int id) { edge[cnt].v=v; edge[cnt].id=id; edge[cnt].next=head[u]; head[u]=cnt++; } void dfs(int u) { for(int i=head[u];i!=-1;i=edge[i].next){ if(!vis[edge[i].id]){ vis[edge[i].id]=1; head[u]=i; dfs(edge[i].v); } i=head[u]; } path[tot++]=u; } void init() { memset(head,-1,sizeof(head)); cnt=tot=0; memset(vis,0,sizeof(vis)); } int main() { int n, m, i, u, v; scanf("%d%d",&n,&m); init(); for(i=0;i
           
            =0;i--){ printf("%d\n",path[i]); } return 0; }