设为首页 加入收藏

TOP

poj3311(Hie with the Pie)状压dp
2015-07-24 05:52:17 来源: 作者: 【 】 浏览:4
Tags:poj3311 Hie with the Pie 状压

题目链接:http://poj.org/problem?id=3311

解法:标准的状压dp类型,先floyd获得两两之间最短距离。然后dp[i][j]表示剩下集合i没走,已经走到j的最短距离;


代码:

/******************************************************
* @author:xiefubao
*******************************************************/
#pragma comment(linker, "/STACK:102400000,102400000")
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #include 
       
         #include 
        
          #include 
         
           #include 
           #include 
           
             #include 
            
              #include 
             
               //freopen ("in.txt" , "r" , stdin); using namespace std; #define eps 1e-8 #define zero(_) (abs(_)<=eps) const double pi=acos(-1.0); typedef long long LL; const int Max=15; const int INF=1e9+7; int dist[Max][Max]; int dp[(1<<13)+3][13]; int n; int getans(int st,int la) { if(dp[st][la]!=-1) return dp[st][la]; int ans=INF; for(int i=0; i<=n; i++) { if((st&(1<
              
               

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇局部静态变量的多线程问题 下一篇POJ 3624 Charm Bracelet 背包题解

评论

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