摘要: 题目中说明每个城市至少要走一次,至多走2次,因此要用到三进制压缩,然后就是状态转移方程了。这道题就处理三进制的地方麻烦一点。同时注意,在选择最小长度时,一定是要每一个点都经过至少一次的,即是状态的每一个三进制位均 >=1.#include #include #include #include usi... 阅读全文
posted @ 2015-03-31 22:00 chenjunjie1994 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 设dp状态为dp[i][j]为当前访问过的结点状态为i且当前停留点为j时的最短路径。用二进制存存储访问过的状态,访问过为1,否则为0。#include #include #include #include using namespace std;const int inf=(1dp[tmp.i][t... 阅读全文
posted @ 2015-03-31 20:29 chenjunjie1994 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 经典的状态压缩DP题了。做了前面两题,就不感觉难了。#include #include #include #include using namespace std;int stack[1>1,r2=st>>2; if(l1&i){flag=false; break;} if(l2&i){... 阅读全文
posted @ 2015-03-31 19:55 chenjunjie1994 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 简单的状态压缩。#include #include #include #include using namespace std;const int Status=1>=1;// coutm-1){ // coutinfer) continue; if((stack[p]&G[i+1])... 阅读全文
posted @ 2015-03-31 11:10 chenjunjie1994 阅读(102) 评论(0) 推荐(0) 编辑