![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
ACM--搜索
南山小翁
活在当下,要有思想,每个人不是随随便便就能成功!
展开
-
搜索题目 一起AC吧
一些好题目 POJ 1190 – 生日蛋糕(基础,好题) http://acm.pku.edu.cn/JudgeOnline/problem?id=1190 题意:略 解法:dfs,题偏简单,但做出来还是有些感觉的 POJ 1376 – Robot(基础) http://acm.pku.edu.cn/JudgeOnline/problem?id=1376 题意:略 解法转载 2012-10-18 20:02:55 · 502 阅读 · 0 评论 -
poj3278 优先队列
给你两个点N,K,从N到K,你有三种移动方案:①N-1②N+1③N*2让你用这三种方案达到K点,问最少需要多少步? #include #include #include #include #include #define max 100001 using namespace std; struct node { int n; int step; bool friend o原创 2013-03-13 21:24:04 · 766 阅读 · 0 评论 -
poj2251 三维搜索 利用优先队列
从S到E问需要多长时间,每走一格浪费 1 minute #include #include #include #include #include using namespace std; struct node { int x; int y; int z; int step; bool friend operator<(node a,node b)原创 2013-03-13 19:32:09 · 747 阅读 · 0 评论 -
poj3083
简单的搜索题目,三中情况:①沿着左边查找②沿着右边查找③找对短路径(具有唯一性)。 #include #include int n,m; int r[4][2]= {{0,-1},{1,0},{0,1},{-1,0}}; int l[4][2]= {{0,1},{1,0},{0,-1},{-1,0}}; int vis[50][50]; char map[50][50]; int sx,sy,e原创 2013-03-12 17:26:06 · 2286 阅读 · 0 评论 -
poj1321
简单的搜索题目:#include #include int n,k; char map[9][9]; int ans; int vis[9]; void dfs(int c,int line) { //记录放的个数和放到的列数 if(line>=n) { if(c==k) { ans++; }原创 2013-03-12 18:11:19 · 1180 阅读 · 0 评论 -
poj2038
题意: 有ABCDE 5个字母,找出它的全排列中的一种排列和输入的n个串中的相对位置不同的个数的和最小。 例如ABCDE和ACBDE,相对位置就BC不一样,即value=1; #include #include #include struct node { //记录全排列的结果。 char pox[110]; int num[10]; }num_a[121],num_b[1原创 2013-03-03 14:01:02 · 741 阅读 · 0 评论 -
hdu http://acm.hdu.edu.cn/showproblem.php?pid=1584 蜘蛛牌
//思路:暴力枚举每一种情况,然后找出最小值 #include #include int num[12]; int vis[12]; int ans; int abs(int a) { if(a>=0) return a; return -a; } void DFS(int time,int re)//记录移动的次数和移动的总和 { if(re>=ans) re原创 2012-12-08 08:44:29 · 869 阅读 · 0 评论 -
poj1606
//题意:给你两个瓶子a和b 他们的体积分别为ca,cb.然后让你对他们进行六种操作 如何配才能得到体积n. #include #include #include #include using namespace std; typedef struct Node { int xx; int yy; } Node; typedef struct Path {原创 2012-11-29 19:10:12 · 893 阅读 · 0 评论 -
poj 1426 http://poj.org/problem?id=1426
//思路:一位一位的扩展,如果满足 ans%n==0 直接返回 #include #include #include using namespace std; long long ans; int n; void BFS() { queue q; q.push(1); while(!q.empty()) { ans=q.fr原创 2012-11-29 19:30:42 · 469 阅读 · 0 评论 -
poj2488
输出路径 按字典序输出路径:#include #include int cood[8][2]= {-2,-1,-2,1,-1,-2,-1,2,1,-2,1,2,2,-1,2,1}; int map[27][27]; int vis[27][27]; int len; int x,y; bool flag; struct Node { int x,y; } node[1000000]; v原创 2012-11-29 11:05:47 · 1807 阅读 · 1 评论 -
hdu1026 http://acm.hdu.edu.cn/showproblem.php?pid=1026
一道打印路径的题目 :学习了 第一次做这种题型#include #include #include #include using namespace std; char map[101][101]; int minTime[101][101]; int roat[4][2]= {0,1,1,0,0,-1,-1,0}; int n,m; int head,last; struct Node {原创 2012-10-21 18:14:38 · 2018 阅读 · 1 评论 -
搜索水题
T - dfs-easy Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Description Product of digits For a given non-negative int原创 2013-04-16 08:03:56 · 804 阅读 · 0 评论