题意:
裸的tsp。
分析:
用bfs求出任意两点之间的距离后可以暴搜也可以用next_permutation水,但效率肯定不如状压dp。dp[s][u]表示从0出发访问过s集合中的点,目前在点u走过的最短路程。
代码:
//poj 2688
//sep9
#include
#include
using namespace std;
const int maxW=32;
const ...
分类:
其他好文 时间:
2015-03-15 10:57:59
阅读次数:
153
中文题 题意不再赘述对于中间这个“P” 根据dp的无后效性 我们只需考虑前面的就变成了 只需考虑:也就是状压前两行具体与HDOJ的4539类似: 看HDOJ 4539仅仅是共存状态的判断不同 1 //#include 2 #include 3 #include 4 #include 5 #i...
分类:
其他好文 时间:
2015-03-15 10:51:18
阅读次数:
229
中文题,题意不再赘述对于“?”这一格,它所能攻击到的(曼哈顿距离为2的) 前方的 即“√”的四个位置那么与此格有关的即它前方两行(即状压这两行)首先预处理每行能满足的:i 和(i<<2)不能同时放然后分别枚举前一行和再前一行的所有状态(每一行的状态至多只有2^10=1024个) 判断能否共存注意mp...
分类:
其他好文 时间:
2015-03-15 10:43:17
阅读次数:
132
Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power ...
分类:
其他好文 时间:
2015-03-14 11:04:05
阅读次数:
122
Language:
Default
Islands and Bridges
Time Limit: 4000MS
Memory Limit: 65536K
Total Submissions: 9312
Accepted: 2424
Description
Given a map of islands and bridge...
分类:
其他好文 时间:
2015-03-14 09:37:51
阅读次数:
150
题目:http://poj.org/problem?id=2404题意:有个n(n<=15)的点和m条无向边,每条边都有自己的权值。现在你要从某个点出发,每条边可以经过多次但要保证每条边至少走一次。现在你要找出一个方案,使得经过所有边的权值和最小,输出最小的权值和。分析:首先容易想到的是如果这个图G...
分类:
其他好文 时间:
2015-03-13 22:20:01
阅读次数:
151
Language:
Default
Hie with the Pie
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 5057
Accepted: 2695
Description
The Pizazz Pizzeria prides itself in...
分类:
其他好文 时间:
2015-03-12 13:23:56
阅读次数:
180
题意:N只FISH。每个回合会有一只FISH吃掉另一个FISH。直到池塘里只剩一只FISH。给出aij:第i只FISH吃掉第J只FISH的概率。问每一只FISH是最后存活者的概率。InputThe first line contains integern(1?≤?n?≤?18) — the amou...
分类:
其他好文 时间:
2015-03-11 16:39:54
阅读次数:
144
HDU 4049 Tourism Planning (状压dp 详解)...
分类:
其他好文 时间:
2015-03-10 15:37:00
阅读次数:
199
Language:
Default
Corn Fields
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 8704
Accepted: 4641
Description
Farmer John has purchased a lush new rect...
分类:
其他好文 时间:
2015-03-10 14:04:39
阅读次数:
135