设为首页 加入收藏

TOP

HDU 4085 斯坦纳树
2015-07-20 18:06:49 来源: 作者: 【 】 浏览:16
Tags:HDU 4085 斯坦

?

因为这题专门花一晚上学习斯坦纳树,找到比较好的学习资料,链接在这里:http://endlesscount.blog.163.com/blog/static/821197872012525113427573/

花了很长时间照着别人写了一份自己风格的代码,慢慢理解:

?

/* ***********************************************
Author :rabbit
Created Time :2014/7/16 20:45:31
File Name :1.cpp
************************************************ */
#pragma comment(linker, /STACK:102400000,102400000)
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include
                using namespace std; #define INF 100000000 #define eps 1e-8 #define pi acos(-1.0) typedef long long ll; const int maxn=60; struct Edge{ int next,to,val; }edge[2100]; int head[maxn],tol,n,m,K; int s[maxn],in[maxn][1<<10],d[maxn][1<<10],dp[1<<10]; void addedge(int u,int v,int c){ edge[tol].to=v; edge[tol].next=head[u]; edge[tol].val=c; head[u]=tol++; } bool check(int x){ int r=0; for(int i=0;x;i++,x>>=1) r+=(x&1)*(i
                
                 >T; while(T--){ memset(head,-1,sizeof(head));tol=0; memset(in,0,sizeof(in)); memset(s,0,sizeof(s)); scanf(%d%d%d,&n,&m,&K); int nn=1<<(2*K); for(int i=1;i<=n;i++) for(int j=0;j
                 
                   Q; for(int x=1;x<=n;x++){ for(int i=(y-1)&y;i;i=(i-1)&y) d[x][y]=min(d[x][y],d[x][i|s[x]]+d[x][(y-i)|s[x]]); if(d[x][y]
                  
                   d[x][y]+edge[i].val){ d[v][y|s[v]]=d[x][y]+edge[i].val; if(y==(y|s[v])&&!in[v][y]){ in[v][y]=1; Q.push(10000*v+y); } } } } } for(int j=0;j
                   
                    =INF)puts(No solution); else printf(%d ,dp[nn-1]); } return 0; } 
                   
                  
                 
                
              
             
            
           
          
         
        
       
      
     
    
   
  


?

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇LeetCode:Implement strStr() 下一篇UVA - 10895 Matrix Transpose

评论

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