- 博客(7)
- 收藏
- 关注
原创 HDU 1584 搜索
DFS爆搜+剪枝即可 #include "stdio.h" #include "string.h" #include "math.h" int ans; int hash[11],a[11]; void dfs(int w,int sum) { int i,j; if (sum>ans) return ; if (w==9) { ans=sum; return ;} for
2014-03-29 14:02:23 503
原创 HDU 1547 搜索
题意:输入n行m列,和发出小球的到达的位置h,w,用a~z表示不同颜色的小球,E表示该位置为空,另外奇数行有m个小球位置,偶数行有m-1个小球位置 求发射出该小球后掉落的小球数量有多少,已知相同颜色的小球连通数量>=3就会掉落和悬空的小球也会掉落 先从发射点DFS出有多少球会掉落 然后从第一行的每一个球DFS 能到的球都不会掉落 其他的全部掉落 注意奇
2014-03-29 13:40:42 531
原创 HDU 1429 搜索
BFS 用二进制压缩判重 #include "queue" #include "iostream" #include "algorithm" #include "string" using namespace std; int dir[4][2]={1,0,-1,0,0,1,0,-1}; struct node { int key,step; int x,y; }; int ans,n,m
2014-03-15 15:04:10 455
原创 HDU 1430 搜索
搜索的好题啊~ BFS预处理出所有的状态,康拓判重,把读入的状态映射到“12345678“。 #include "queue" #include "string" #include "iostream" #include "algorithm" using namespace std; int fac[10]={1,1,2,6,24,120,720,5040,40320,36288
2014-03-15 14:22:11 527
原创 HDU 1074 状压DP
状态压缩DP 模板 感觉叫 状态压缩搜索更合适。。。 #include "iostream" #include "algorithm" const int inf=0x7fffffff; struct comp { char name[101]; int et,cost; } data[21]; int b[21],hash[21]; int sum[1<<16];// 存储代价 cha
2014-03-12 16:18:23 492
原创 HDU 1254 搜索
#include "queue" #include "iostream" #include "algorithm" #include "string" using namespace std; int dir[4][2]={1,0,-1,0,0,1,0,-1}; int ans,n,m; int mark[10][10][101]; struct node
2014-03-05 20:46:34 660
原创 HDU 1226 搜索
BFS用余数来判重,因为n最大5000,只需要存储5000以内的余数即可; n==0 时特殊考虑一下 #include "queue" #include "string" #include "iostream" using namespace std; struct node { int mod; string ans; }; int n,c,flag; string ans; int
2014-03-05 19:51:59 526
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人