
搜索
文章平均质量分 78
acmdream
我是福建某高校2013级在校生,学业之余喜欢研究算法。
展开
-
HDU 1010(dfs+奇偶剪枝)
题意:'X': a block of wall, which the doggie cannot enter; 'S': the start point of the doggie; 'D': the Door; or'.': an empty block.doggie在起点'S'的时候地板开始下陷,他必须马上移动,'X'是墙,不能通过,'.'是地板,可以通过,但是一走过地板就原创 2014-01-11 14:14:19 · 739 阅读 · 0 评论 -
HDU 1312(BFS)
题意:“.”是red方格,“#”是black方格,“@”是起点。求从起点开始走,可以到达的方格(包括起点),red方格不能走,相当于墙壁。 #include #include #include using namespace std;char map[25][25];bool visit[25][25];int count;const int directi原创 2014-01-16 21:47:14 · 613 阅读 · 0 评论 -
HDU 1298(字典树+dfs)
题意:给一个T,表示输入数据的组数。给一个n,表示字典的大小。接下来有n行,每行有一个字符串和一个数字,数字表示为这个字符串的权值。接下来给一个m,表示手机按键的串号,结尾1表示当前输入结束,进行下一个字符。输出每一步按键应该出现的字符串。 #include #include #include using namespace std;struct Trie{原创 2014-01-16 21:16:38 · 804 阅读 · 0 评论 -
HDU 1253(BFS)
题意:如题。#include #include #include #include #include using namespace std;int A, B, C, T;int step[6][3] = { {1, 0, 0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1} };int cas原创 2014-01-16 11:13:47 · 553 阅读 · 0 评论 -
HDU 1258(dfs)
题意:给出t,n,还有n个非递增的正整数,求用这些非递增的正整数中挑选出可以相加成t的组合。#include #include #include #include #include using namespace std;int num[101];int amount[101];int box[13];bool done;void DFS(int s原创 2014-01-16 18:47:45 · 504 阅读 · 0 评论 -
HDU 1254(BFS)
题意:如题。#include #include #include #include using namespace std;const int S[][3] = { {0, 1, 0}, {1, -1, 0}, {2, 0, 1}, {3, 0, -1} };char map[9][9];bool visit[9][9][4];int M, N;inli原创 2014-01-16 11:20:16 · 563 阅读 · 0 评论 -
HDU 1198(并查集;dfs)
题意:给出a-k个图形,求由这些图形拼凑起来的图中的管道一共有几个连通管道。 并查集: #include#include//char str[2][9]={{"ABEGHJK"},{"ACFGHIK"}};int f[2505],m,n;char map[52][52];int check(int x,int y){ if(x>=0 &&原创 2014-01-15 16:41:53 · 478 阅读 · 0 评论 -
HDU 1242(bfs)
题意:一个朋友拯救angel,'a' 是angel, 'x'是士兵, 'r'是朋友,'#'是墙壁。没走一步花费一个单位的时间,遇到士兵与士兵搏斗花费一个单位的时间,求最短时间。 #include #include #include #include using namespace std;struct Point{ int x, y, time;原创 2014-01-15 21:37:55 · 558 阅读 · 0 评论 -
HDU 1226(bfs,大数求余)
题意:如题。。这道题注意如何求余,如何剪枝。 #include #include #include #include using namespace std;int num[20],vis[5005];int n,c,m;struct node{ int s[505];//将每一位的字符压入此数组 int len;};原创 2014-01-15 20:42:32 · 619 阅读 · 0 评论 -
HDU 1240(bfs)
题意:给出一个三维空间,宇宙飞船的起始地点,目标地点,求最短飞行距离。 #include #include #include #include using namespace std;int N;int step[6][3] = { {1, 0 ,0}, {-1, 0, 0}, {0, 1, 0}, {0, -1, 0}, {0, 0, 1}, {0, 0, -1}原创 2014-01-15 21:32:12 · 594 阅读 · 0 评论 -
HDU 1195(bfs)
题意:如题。 #include #include #include #include using namespace std;bool visit[10000];const int temp[5] = {0, 1000, 100, 10, 1};/*int swap(int num, int x, int y){ int temp[5],原创 2014-01-15 16:04:54 · 513 阅读 · 0 评论 -
HDU 1180(bfs)
题意:如题。 #include #include #include #include #include using namespace std;struct Point{ int x, y, time; bool operator <(const Point& rhs) const { return time原创 2014-01-15 15:50:33 · 578 阅读 · 0 评论 -
HDU1175(bfs)
题意:如题。#include #include #include #include #include using namespace std;#define LEFT 3#define RIGHT 2#define UP 1#define DOWN 0#define EMPTY -1int step[4][3] = { {0, 1, 0},原创 2014-01-14 23:43:10 · 594 阅读 · 0 评论 -
HDU 1172(dfs)
题意:如题。 #include #include #include #include #include #define MIN( x, y ) (x) < (y) ? (x) : (y)using namespace std;struct Node{ char num[10]; int right, pos; }n[105]原创 2014-01-14 23:41:34 · 534 阅读 · 0 评论 -
HDU 1072(bfs)
题意:主人公在一块6秒钟后要爆炸的范围内,主人公没走一步需要1秒,0是墙壁,1是路,2是起点,3是目标,4是爆炸时间从新设置,如果刚好在0秒到达3或者4都算输,每个可到达位置都可以重复到达,求主人公多短时间能够走出去,如果走不出去输出-1. 使用优先队列: #include#include#include#includeusing namespace std;i原创 2014-01-13 11:09:16 · 532 阅读 · 0 评论 -
HDU 1044(bfs+dfs)
#include#include #includeusing namespace std;int n,m,t,w;int val[60];char map[60][60];int vis[60][60],vis2[60],step[60][60];queue q;int d[4][2]={-1,0,1,0,0,-1,0,1};int abc[60][60],原创 2014-01-12 17:29:44 · 578 阅读 · 0 评论 -
HDU 1026(bfs)
题意:如题。#include #include #include #include #include using namespace std;int N, M;const int step[4][3] = { {0, 1, 0}, {1, -1, 0}, {2, 0, 1}, {3, 0, -1} };int time[101][101];int LD[原创 2014-01-12 10:57:15 · 458 阅读 · 0 评论 -
HDU 1016(dfs)
题意:给一个数n,求1~n围成一个圆环,圆环相邻的两个数相加为质数,输出所有可能。 #include #include #include #include using namespace std;bool prim[40];int num[25];bool used[25];//筛法void is_prim(){ memset(prim,0原创 2014-01-11 14:32:40 · 547 阅读 · 0 评论 -
HDU 1067(HASH + BFS)
题意:如图分部这的卡片,每次移动一个空格,让比空格左边的数大一的数移动到空格。最后达到目标状态。问最少的步数。#include#include#include#include#includeusing namespace std;#define MAXN 1000007typedef long long ll;ll Hash[MAXN];struct N原创 2014-01-12 23:18:46 · 854 阅读 · 0 评论