传送门 题意:找一个经过所有边权值最小的回路,$n \le 15$ 所有点度数为偶则存在欧拉回路,直接输出权值和 否则考虑度数为奇的点,连着奇数条边,奇点之间走已经走过的路移动再走没走过的路 然后大体想一想就是权值和加上奇点的最小权匹配啦 蒟蒻不会带花树就打了状压$DP$ $f[s]$表示已经选的集合为$s$,考虑当前未选的最小点和哪一个未选的点匹配 #include <iostream> #include <cstdio> #include <cstring> #in…
[题目链接] http://poj.org/problem?id=2404 [题目大意] 给出一张图,求走遍所有的路径至少一次,并且回到出发点所需要走的最短路程 [题解] 如果图中所有点为偶点,那么一定存在欧拉回路, 否则一定存在偶数个奇点,将这些奇点取出构建新图, 任意两点之间的边权威原图中两点的最短距离, 用状压DP求最小权完美匹配,加上原图所有边权和就是答案. [代码] #include <cstdio> #include <algorithm> #include <c…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1086 题解:题目就是求欧拉回路然后怎么判断有欧拉回路只要所有点的度数为偶数.那么就有欧拉回路所以只要找出度数为奇数的点然后在度数为奇数点之间选择两个这可以用状压来解决(由于无向图总的度数肯定是偶数的所以奇数度数的点肯定只有偶数个). #include <iostream> #include <cstring> #include <cstdio> #i…
Jogging Trails Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2122   Accepted: 849 Description Gord is training for a marathon. Behind his house is a park with a large network of jogging trails connecting water stations. Gord wants to f…
题目:http://poj.org/problem?id=2288 状压挺明显的: 一开始写了(记忆化)搜索,但一直T: #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int const inf=0x3f3f3f3f; ]; ll ans,cnt,f[<<];…
题目 传送门:QWQ 分析 数位dp 状压一下现在的$ O(nlogn) $的$ LIS $的二分数组 数据小,所以更新时直接暴力不用二分了. 代码 #include <bits/stdc++.h> using namespace std; typedef long long ll; ; ll dp[maxn][<<][];int k,digit[maxn]; int nextstate(int state,int x){ ;i++){ <<i)){ state^=(&…
[题意]n种宝物,k关游戏,每关游戏给出一种宝物,可捡可不捡.每种宝物有一个价值(有负数).每个宝物有前提宝物列表,必须在前面的关卡取得列表宝物才能捡起这个宝物,求期望收益.k<=100,n<=15. [算法]期望DP+状压DP [题解]主要需要记录的状态是前缀已有宝物,所以设f[i][S]表示前i关已有宝物列表S的期望收益. 根据全期望公式,依赖于第i+1关的宝物选择:(如果列表符合) $$f[i][S]=\sum_{i=1}^{n}\frac{1}{n}*Max(f[i+1][S'],f[…
传送门:http://poj.org/problem?id=3565 Ants Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 7650   Accepted: 2424   Special Judge Description Young naturalist Bill studies ants in school. His ants feed on plant-louses that live on apple tree…
[POJ 2195] Going Home(KM算法求最小权匹配) Going Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20303   Accepted: 10297 Description On a grid map there are n little men and n houses. In each unit time, every little man can move one unit ste…
炮兵阵地 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 26426   Accepted: 10185 Description 司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队.一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(用"P"表示),如下图.在每一格平原地形上最多可以布置一支炮兵部队(山地上不能够部署炮兵部队):一支炮兵部队在地图上的攻…