设为首页 加入收藏

TOP

UVA 10735 混合图的欧拉回路+输出路径
2015-07-20 17:36:16 来源: 作者: 【 】 浏览:3
Tags:UVA 10735 混合 回路 输出 路径
#include
  
   
#include
   
     #include
    
      #include
     
       #include
      
        #include
       
         #include
         #include
         
           #include
          
            #include
           
             #define eps 1e-12 #define INF 0x7fffffff #define maxn 22222 using namespace std; int n,m; int en; int st,ed; int dis[maxn] ; int que[999999]; int cur[maxn],head2[maxn],en2; struct edge { int to,c,next; }e2[999999]; edge e[999999]; int head[maxn],in[maxn],out[maxn]; void add(int a,int b,int c) { e[en].to=b; e[en].c=c; e[en].next=head[a]; head[a]=en++; e[en].to=a; e[en].c=0; e[en].next=head[b]; head[b]=en++; } void add(int a,int b) { // printf("%d->%d\n",a,b); e2[en2].to=b; e2[en2].next=head2[a]; head2[a]=en2++; } int bfs() { memset(dis,-1,sizeof(dis)); dis[st]=0; int front=0,rear=0; que[rear++]=st; while(front
            
             in[i]) { add(st,i,(out[i]-in[i])/2),sum+=(out[i]-in[i])/2; } else { add(i,ed,(in[i]-out[i])/2); } } if(sum==dinic()) { for(int i=1;i<=n;i++) for(int j=head[i];~j;j=e[j].next) { if(e[j].to>=1&&e[j].to<=n) { if(e[j].c)add(i,e[j].to); } } dfs2(1); printf("%d",ans[top-1]); for(int i=top-2;i>=0;i--) printf(" %d",ans[i]); puts(""); } else puts("No euler circuit exist"); } int main() { int cas; scanf("%d",&cas); while(cas--) { scanf("%d%d",&n,&m); init(); build(); } return 0; } 
            
           
          
         
       
      
     
    
   
  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C++图像辅助工具包Eigen入门代码.. 下一篇POJ 3233 Matrix Power Series(..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·PostgreSQL 索引 - (2025-12-25 22:20:43)
·MySQL Node.js 连接 (2025-12-25 22:20:41)
·SQL 撤销索引、表以 (2025-12-25 22:20:38)
·Linux系统简介 (2025-12-25 21:55:25)
·Linux安装MySQL过程 (2025-12-25 21:55:22)