图论 搜索
Hearthougan
这个作者很懒,什么都没留下…
展开
-
九度 题目1457:非常可乐
题目来源:http://ac.jobdu.com/problem.php?pid=1457原创 2014-06-18 15:30:58 · 1176 阅读 · 0 评论 -
zoj 1019 Illusive Chase
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1019#include #include #include #include using namespace std;const int MAXN = 1010;int row, col;int Graph[MAXN][MAXN];int r原创 2014-04-09 20:53:56 · 1914 阅读 · 0 评论 -
Nyoj 587blockhouses zoj 1002 Fire Net
题目来源:Nyojhttp://acm.nyist.net/JudgeOnline/problem.php?pid=587zojhttp://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=2原创 2014-04-09 17:20:17 · 985 阅读 · 0 评论 -
zoj 1008
题目来源:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=8之前的写法:原创 2014-04-09 14:56:35 · 644 阅读 · 0 评论 -
NYOJ 927 The partial sum problem
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=927原创 2014-04-07 09:37:01 · 994 阅读 · 0 评论 -
Nyoj 722 数独
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=722原创 2014-04-06 19:15:09 · 1279 阅读 · 0 评论 -
NYOJ 353 3D dungeon + zoj 1940 Dungeon Master
其实跟二维的一样,注意方向。原创 2014-04-05 18:11:08 · 1266 阅读 · 0 评论 -
Nyoj 284 坦克大战
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=284跟zoj原创 2014-04-05 14:07:57 · 737 阅读 · 0 评论 -
poj 2676 sudoku
题目来源:http://poj.org/problem?id=2676跟原创 2014-04-06 20:36:36 · 1118 阅读 · 0 评论 -
NYoj 491
这个也能打表,真不不知道原创 2014-04-06 10:37:09 · 891 阅读 · 0 评论 -
九度 题目1120:全排列
题目来源:http://ac.jobdu.com/problem.php?pid=1120时间限制:1 秒内存限制:32 兆特殊判题:否提交:2847解决:692题目描述:给定一个由不同的小写字母组成的字符串,输出这个字符串的所有全排列。我们假设对于小写字母有'a' 输入:输入只有一行,是一个由不同的小原创 2014-06-16 17:05:35 · 1120 阅读 · 0 评论 -
九度 题目1456:胜利大逃亡
题目来源:http://ac.jobdu.com/problem.php?pid=1456原创 2014-06-17 09:25:33 · 725 阅读 · 1 评论 -
(搜索) 跳棋系列9
跳棋#8TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个 方向跳,即前后左右4个方向。还可以挪步,即往4个方向走1步,但挪步只能挪一次。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 1 1 1 0 1原创 2014-08-11 20:23:36 · 565 阅读 · 0 评论 -
(搜索) 跳棋系列1
跳棋#1TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个方向跳,即前后左右4个方向。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 0 1 0 0 0 0 2 0 0 1 2 3 2 1 0 0 2 0原创 2014-08-08 19:27:22 · 891 阅读 · 0 评论 -
(搜索)跳棋系列4
跳棋#4TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个 方向跳,即前后左右4个方向。还可以挪步,即往4个方向走1步,但挪步只能挪一次。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 1 1 1 0 1原创 2014-08-08 20:28:53 · 596 阅读 · 0 评论 -
(搜索)跳棋系列7
跳棋#7TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个方向跳,即前后左右4个方向。还可以挪步,即往4个方向走1步。如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。1 1 1 1 11 1 2 1原创 2014-08-08 21:28:27 · 642 阅读 · 0 评论 -
(搜索)跳棋系列6
跳棋#6TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔两个子往4个 方向跳,即前后左右4个方向。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 0 1 2 2 1 2 2 1 0 0 2 0 0 2 0 0 2原创 2014-08-08 21:19:18 · 606 阅读 · 0 评论 -
(搜索)跳棋系列2
跳棋#2TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔两个子往4个 方向跳,即前后左右4个方向。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 0 1 2 2 1 2 2 1 0 0 2 0 0 2 0 0 2原创 2014-08-08 19:51:00 · 766 阅读 · 0 评论 -
(搜索)跳棋系列5
跳棋#5TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个 方向跳,即前后左右4个方向。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 0 0 1 0 0 0 0 2 0 0 1 2 3 2 1 0 0 2原创 2014-08-08 21:07:26 · 640 阅读 · 0 评论 -
(搜索)跳棋系列3
跳棋#3TimeLimit: 1 Second MemoryLimit: 32 MegabyteDescription大家都玩过跳棋的游戏吧,正常的跳棋游戏能隔子往6个方向跳,在本题中只能隔一个子往4个 方向跳,即前后左右4个方向。还可以挪步,即往4个方向走1步,步数不限。 如图,3代表要跳的棋子,2代表普通的棋子,1代表棋子3能跳到的位置,0代表空地。 1 1 1 1 1 1 1 2原创 2014-08-08 20:11:55 · 637 阅读 · 0 评论 -
九度 题目1461:Tempter of the bone
题目来源:http://ac.jobdu.com/problem.php?pid=1461原创 2014-06-17 19:40:23 · 854 阅读 · 0 评论 -
hdu 1253 胜利大逃亡
题目来源:http://acm.hdu.edu.cn/showproblem.php?pid=1253#include #include #include #include using namespace std;const int MAXN = 55;const int INF = 0xffffff;int Graph[MAXN][MAXN][MAXN];int MinT原创 2014-04-05 19:47:21 · 619 阅读 · 0 评论 -
poj 2362 Square
题目来源:http://poj.org/problem?id=2362跟poj1011, nyoj原创 2014-04-05 16:37:56 · 629 阅读 · 0 评论 -
hdu 2553 n皇后问题
#include #include #include #include using namespace std;const int MAXN = 15;int row[MAXN], sum, n;//row[num] = i,表示第num行皇后放在第i列int ans[MAXN];bool Judge(int num)//判断num行,row[num]列之前,是否存在冲突原创 2014-03-18 10:38:32 · 910 阅读 · 0 评论 -
Nyoj 456
#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 12;int num[MAXN];int totalvalue;bool DFS(int sum){ if(sum == totalvalue)...原创 2014-03-27 20:08:06 · 773 阅读 · 0 评论 -
zoj 1083 Frame Stacking
#include #include #include using namespace std;const int SIZE=30,NUM=26;struct square{ int up, right, down, left;}alpha[NUM];int N,M,cnt,id[NUM];//cnt 图的种类数目,id[i]表示顶点i的入度bool cover[SIZE原创 2013-10-15 21:20:03 · 1007 阅读 · 0 评论 -
ZOJ 1649 Rescue
本题要求从r 位置出发到达Angel所在位置并且所需时间最少,适合采用BFS求解。但是BFS算法求出来的最优解通常是步数最少的解,而在本题中,步数最少的解不一定是最优解. 在本题中,并没有使用标明各位置是否访问过的状态数组visited,也没有在BFS过程中将访问过的相邻位置设置成不可再访问,那么BFS过程会不会无限搜索下去呢?实际上是不会的,因为从某个位置出发判断是否需要将它的相邻位原创 2013-10-07 11:41:14 · 958 阅读 · 0 评论 -
2412 ZOJ Farm Irrigation
/**因为每一块地,最多只有四个水管的接口,故而可以把每一块土地上,下,左,右,都标记成0或1(0,代表该方向没有接口;1,代表该方向有接口)DFS(int x, int y){从第一块开始搜索,如果:该土地的1.Land[x][y].up=1,则如果和其他土地连通必有,Land[x-1][y].down = 1;(注意:Land[x-1][y]是在Land[x][y]的上方)2.Lan原创 2013-07-25 09:26:29 · 531 阅读 · 0 评论 -
zoj 1709 Oil Deposits
题目 点击打开链接#include #include using namespace std;const int MAXN = 105;char map1[MAXN][MAXN];int dir[8][2] = { {-1, 0}, {-1, -1}, {0, -1}, {1, -1}, {1, 0}, {1, 1}, {0, 1}, {-1, 1} };int m, n;v原创 2013-10-06 10:35:39 · 858 阅读 · 0 评论 -
zoj 1008 Gnome Tetravex
题目 点击打开链接 #include #include using namespace std;const int MAXN = 50;int map1[MAXN][MAXN];//存放的是已匹配的方块标号,如果可以实现题目结果,则最后map1中即是所求的一种情况。int n;bool tmp;struct Node{ int up, right, do原创 2013-10-06 21:14:17 · 756 阅读 · 0 评论 -
2412 zoj
/**因为每一块地,最多只有四个水管的接口,故而可以把每一块土地上,下,左,右,都标记成0或1(0,代表该方向没有接口;1,代表该方向有接口)DFS(int x, int y){从第一块开始搜索,如果:该土地的1.Land[x][y].up=1,则如果和其他土地连通必有,Land[x-1][y].down = 1;(注意:Land[x-1][y]是在Land[x][y]的上方)2.Lan原创 2013-10-06 13:01:45 · 669 阅读 · 0 评论 -
hdu 2377 zoj 2913
点击打开题目本题就是求中心区域设置一个数组res[i]用来存放每一个区域i到达公交路线上所有区域的最大值,最后再求res[i]的最小值,则i即是求得的中心区域;利用BFS搜索以及滚动数组的特性即可以求出。 参见代码:#include #include #include #include #include using namespace std;#defi原创 2013-10-07 14:09:30 · 875 阅读 · 0 评论 -
Nyoj 42 一笔画问题
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=42 无向图G存在欧拉通路的充要条件是:G为连通图,并且G仅有两个奇度顶点(度数为奇数的顶点),或者无奇度顶点当然可用并查集来解,找出奇度顶点的个数,记录集合的个数,然后根据充要条件判断!#include #include #include using namespa原创 2014-04-04 08:45:13 · 789 阅读 · 0 评论 -
Nyoj 325
//利用搜索来实现在均分(意思就是这个人的多少,多方就得多少)的情况下,使得两堆误差最小(总的质量之和减去两者均分量之和,就是在此种均分情况下的两堆差量)!#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 25;...原创 2014-03-24 11:19:34 · 721 阅读 · 0 评论 -
Nyoj 488 素数环
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=488#include #include #include using namespace std;const int MAXN = 55;bool IsPrime[MAXN], visit[MAXN];int arr[MAXN];int n;void Ch原创 2014-04-05 21:58:11 · 787 阅读 · 0 评论 -
Nyoj 293 + poj 1011 Sticks
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=293深搜的原创 2014-04-05 15:19:47 · 945 阅读 · 0 评论 -
Nyoj 202 红黑树
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=202跟红黑树毛关系原创 2014-04-05 09:58:11 · 923 阅读 · 0 评论 -
NYoj 58 最少步数
广搜,尽量自己写队列!StL除了节省写代码的原创 2014-04-04 16:21:45 · 693 阅读 · 0 评论 -
Nyoj 82 迷宫寻宝(一)
题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=82原创 2014-04-04 19:28:41 · 847 阅读 · 0 评论 -
Nyoj 20 吝啬的国度
题目来源:原创 2014-04-03 14:51:08 · 818 阅读 · 0 评论