
搜索
一只会旅行的猫
这个作者很懒,什么都没留下…
展开
-
【IDA*】hdu 1560
#include #include #include using namespace std;const int NM=10;char str[NM][NM],cs[4]={'A','C','T','G'};int v[NM],len[NM],sta[NM],dep,n;bool flag;int compare() //A*的估价函数{i原创 2014-05-23 17:01:46 · 520 阅读 · 0 评论 -
【BFS+Prim】poj 3026 Borg Maze
http://poj.org/problem?id=3026题意:从S开始找到一条到所有外星人A的通路,使得该通路总长度最短。分析:暴搜找出所有A/S之间的边,然后用prim把所有最短的边连接起来。#include #include #include #include using namespace std;const int NM=105;/*k:外星人的个数,原创 2014-03-26 20:53:18 · 479 阅读 · 0 评论 -
【DFS】hdu 2616 Kill the monster
http://acm.hdu.edu.cn/showproblem.php?pid=2616分析:排列树水过#include #include #include using namespace std;const int NM=15;int cost[NM],x[NM],spe[NM],mmin,n;void DFS(int t,int MP,int cc){原创 2014-04-02 20:03:02 · 499 阅读 · 0 评论 -
poj 1664 放苹果
http://poj.org/problem?id=1664原创 2014-04-17 19:35:31 · 446 阅读 · 0 评论 -
hdu 2209 翻纸牌游戏
http://acm.hdu.edu.cn/showproblem.php?pid=2209分析:第1张牌的状态只受两种影响:自己和第2张牌;判断前一张牌是否为正面#include #include #include #include using namespace std;const int NM=25;int mmin,len,a[NM];bool flag原创 2014-04-01 18:33:33 · 667 阅读 · 0 评论 -
【DFS】hdu 1045 Fire Net
http://acm.hdu.edu.cn/showproblem.php?pid=1045分析:从第一个点到最后一个点依此暴搜#include #include #include using namespace std;const int NM=10;char str[NM][NM];bool vis[NM][NM];int mmax,num,n;bool原创 2013-07-17 10:47:15 · 612 阅读 · 0 评论 -
【DFS(记忆化)】hdu 1619 Unidirectional TSP
http://acm.hdu.edu.cn/showproblem.php?pid=1619原创 2014-04-16 20:37:38 · 608 阅读 · 0 评论 -
【DFS(记忆化)】poj 1351 Number of Locks
http://poj.org/problem?id=1351题意:原创 2014-04-16 18:31:40 · 520 阅读 · 0 评论 -
hdu 2612 Find a way(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=2612分析:两个好基友在固定地点见面,分别对这两人BFS,注意要预先处理步数#include#include#includeusing namespace std;const int NM=205;const int MAX=0xfffff;char str[NM][NM];int a[4原创 2013-07-26 20:30:39 · 573 阅读 · 0 评论 -
hdu 3316 Mine sweeping(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=3316分析:当遇到k=0时电脑会自动触发周围的8个方向点,8个方向中有地雷则不会点击该点,其余继续搜寻#include#include#include#includeusing namespace std;const int NM=105;char str[NM][NM];int a[8]原创 2013-07-27 23:14:49 · 791 阅读 · 0 评论 -
hdu 2531 Catch him(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=2531分析:没啥说的,只是把防守队员整体当成一个点即可#include#include#includeusing namespace std;const int NM=105;char str[NM][NM];int vis[NM][NM],n,m;int a[4][2]={-1,0,1,原创 2013-07-28 17:51:41 · 724 阅读 · 0 评论 -
【DFS(记忆化)】hdu 2452 Navy maneuvers
http://acm.hdu.edu.cn/showproblem.php?pid=2452原创 2014-04-21 21:40:15 · 605 阅读 · 0 评论 -
【Dijkstra+DFS(记忆化)】hdu 1142 A Walk Through the Forest(外:hdu 1428)
http://acm.hdu.edu.cn/showproblem.php?pid=1142#include#include#includeusing namespace std;const int MAX=0x3fffffff;const int NM=1005;int n;int a[NM][NM];int p[NM],f[NM],flag[NM];vo原创 2013-08-10 18:38:07 · 541 阅读 · 0 评论 -
hdu 2425 Hiking Trip(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=2425题意:有四种材质的路,三种path,sand,tree可以通过,通过时间依此增大;注意刚开始的地点时间不用计算,终点位置通过的时间需要加上分析:这个不能用到达最短步数来衡量,需要遍历整个迷宫找出的最小时间#include#include#includeusing namespace std原创 2013-08-17 15:51:29 · 846 阅读 · 0 评论 -
【树形DP】hdu 1520 Anniversary party
http://acm.hdu.edu.cn/showproblem.php?pid=1520#include #include #include #include using namespace std;const int NM=6005;int dp[NM][2],f[NM],a[NM];vectorv[NM];int max(int x,int y){ ret原创 2014-05-23 16:51:59 · 495 阅读 · 0 评论 -
【DFS】poj 1190 生日蛋糕
http://poj.org/problem?id=1190#include #include using namespace std;const int MAX=0xfffffff;int mmins;int V,M;int Get_minV(int x){ return (x+1)*(x+1)*x*x/4;}/* V=PI*r^2*h; S(侧)=2*PI*r原创 2014-05-23 16:56:51 · 710 阅读 · 0 评论 -
【DFS】poj 1426 Find The Multiple
http://poj.org/problem?id=1426#include #include #include using namespace std;typedef __int64 LL;const int NM=205;int n,vis[NM];LL BFS(){ queueq1; LL t=1,x1,x2; int mod1,mod2; memse原创 2014-05-23 17:23:15 · 639 阅读 · 0 评论 -
【DFS】nyoj 82 迷宫寻宝(一)
http://acm.nyist.net/JudgeOnline/problem.php?pid=82 #include#include#include#include#includeusing namespace std;char str[25][25];int b[5],c[5],doorx[5],doory[5],vis[25][25],s原创 2013-06-10 23:32:53 · 714 阅读 · 0 评论 -
【BFS/Dijkstra】hdu 1548 A Strange Lift
#include#includeconst int NUM=0xfffff;int a[205][205],f[205],d[205];int main(){int n,i,j,x,y,m,tt,MIN;while(scanf("%d",&n),n!=0){for(i=1;i{a[i][i]=0;for(j=1;ja[i][j]=a[j][i]=原创 2013-06-22 14:26:00 · 637 阅读 · 0 评论 -
nyoj 43 24 Point game
http://acm.nyist.net/JudgeOnline/problem.php?pid=43分析:#include #include #include #include using namespace std;const int NM=15;const double eps=1e-6;bool vis[NM],flag;double a[NM];int n,m原创 2014-05-14 19:10:46 · 469 阅读 · 0 评论 -
【DFS(记忆化)】hdu 1078 FatMouse and Cheese(poj 1088 滑雪)
#include #include #include #include using namespace std;const int NM=105;int a[NM][NM],vs[NM][NM],n,k,mmax;int d[4][2]={-1,0,1,0,0,-1,0,1};int max(int x,int y){return x>y?x:y原创 2014-04-10 17:20:01 · 560 阅读 · 0 评论 -
【字典树+DFS】hdu 1298 T9
http://acm.hdu.edu.cn/showproblem.php?pid=1298原创 2014-05-18 21:35:36 · 557 阅读 · 0 评论 -
nyoj 927 The partial sum problem
#include #include #include #include using namespace std;const int NM=30;int a[NM],sum,n;bool flag;bool comp(int x,int y){ return x>y;}void DFS(int res,int i){ if(flag || i>n) return;原创 2014-05-16 21:35:02 · 593 阅读 · 0 评论 -
【DFS(记忆化)】hdu 1208 Pascal's Travels
http://acm.hdu.edu.cn/showproblem.php?pid=1208分析:注意当出现0时,原创 2014-04-10 16:14:40 · 560 阅读 · 0 评论 -
【DFS(记忆化)】zzuli 1430 多少个0
#include #include #include using namespace std;const int NM=105;const int MAX=0xfffffff;int dp[NM][NM][2],a[NM][NM],mmin,n,m;int c[2][2]={1,0,0,1};int MIN(int x,int y){ return x<y?x:y;}i原创 2014-04-23 11:06:30 · 511 阅读 · 0 评论 -
【DFS】hdu 2553 N皇后问题
#include#includeint sum,n,hang[15],xie1[25],xie2[25];void DFS(int i){ int j; if(i>n) sum++; else {for(j=1;j{if(!hang[j]&&!xie1[i+j]&&!xie2[n-i+1+j]) //列、对角线{hang原创 2013-07-03 18:23:04 · 752 阅读 · 0 评论 -
【DFS+BFS】hdu 1983 Kaitou Kid - The Phantom Thief (2)(迷宫)
http://acm.hdu.edu.cn/showproblem.php?pid=1983分析:最多只用封锁四个位置就可以了(封锁起点或终点);判断路径是否经过时,再加一层宝石状态来判断(可以重复走)#include #include #include #include using namespace std;const int NM=10;int a[4][2]=原创 2014-03-30 19:44:41 · 686 阅读 · 0 评论 -
hdu 4198 Quick out of the Harbour
http://acm.hdu.edu.cn/showproblem.php?pid=4198分析:计算最小时间时间#include#include#includeusing namespace std;const int NM=505;const int MAX=0x3fffffff;char str[NM][NM];int vis[NM][NM],n,m,d,x1,y1,原创 2013-08-17 19:37:17 · 584 阅读 · 0 评论 -
【DFS】hdu 2780 Su-Su-Sudoku
http://acm.hdu.edu.cn/showproblem.php?pid=2780分析:我去,注意可能输入的矩阵就不符合要求,以及最后一行不用再多输出空格了(各种处理,真的好讨厌)回溯搜索#include#include#includeusing namespace std;const int NM=9;int vis[10],v1[10],v2[10],v3[1原创 2013-08-14 00:25:49 · 609 阅读 · 0 评论 -
【DFS】hdu 1426 Sudoku Killer
http://acm.hdu.edu.cn/showproblem.php?pid=1426分析:同hdu 2780相同,注意退细节的处理#include#include#includeusing namespace std;const int NM=20;int a[NM][NM],vis[NM],k,flag;struct Sudu{ int x,y;}s[原创 2013-08-14 18:40:50 · 563 阅读 · 0 评论 -
hdu 2822 Dogs
http://acm.hdu.edu.cn/showproblem.php?pid=2822分析:遇到'.'(挖隧道)的时候才需要步数加1,'X'是一个整体,利用优先队列选择步数最小的开始广搜不过这样效率比较低,可以用双搜加快效率#include#include#includeusing namespace std;const int NM=1005;int a[4][2]原创 2013-08-11 12:20:55 · 495 阅读 · 0 评论 -
【BFS+DFS】hdu 1254 推箱子
http://acm.hdu.edu.cn/showproblem.php?pid=1254分析:以箱子的路线为主,判断人是否能到达推箱子的地点,通过箱子只能走不同方向(vis[NM][NM][[4])一次标记#include#include#includeusing namespace std;const int NM=10;int a[4][2]={-1,0,1,0,0,1原创 2013-08-11 16:00:22 · 632 阅读 · 0 评论 -
hdu 1240 Asteroids!
http://acm.hdu.edu.cn/showproblem.php?pid=1240分析:三维数组,同二维相同,同类型:hdu 1253 胜利大逃亡#include#include#includeusing namespace std;const int NM=15;int a[6][3]={{-1,0,0},{1,0,0},{0,-1,0},{0,1,0},{0,原创 2013-07-25 20:20:24 · 564 阅读 · 0 评论 -
hdu 2102 A计划
http://acm.hdu.edu.cn/showproblem.php?pid=2102分析:遇到‘#’就跳到另外一层,本来想到两层相同位置同时为’#‘会发生冲突,没想到还是脑抽了认为已经考虑到这种情况了,还狂找bug,看来还是不够细心和自信,努力之#include#include#includeusing namespace std;const int NM=11;cha原创 2013-07-19 23:32:26 · 587 阅读 · 0 评论 -
hdu 1175 连连看(外一篇)
http://acm.hdu.edu.cn/showproblem.php?pid=1175分析:因为转弯次数的限制,用一直走到底的方法,其他各种方法变换搜索方向顺序均不能通过,是错误的#include#include#includeusing namespace std;const int NM=1005;struct Node{ int x,y,turn;};int原创 2013-07-17 13:08:35 · 548 阅读 · 0 评论 -
nyoj 21 三个水杯
http://acm.nyist.net/JudgeOnline/problem.php?pid=21分析:可以倒水的共有6种情况,即:1-2,1-3,2-3,3-2,3-2,2-1(需要判断倒水杯子是否有水,被倒的杯子是否满了)然后bfs,啊~~#include#include#include #include using namespace std;int V1,V2,原创 2013-06-20 23:17:54 · 681 阅读 · 0 评论 -
nyoj 92 图像有用区域
http://acm.nyist.net/JudgeOnline/problem.php?pid=92分析:主要找出在线圈内的像素和先圈外的像素有神马区别,我的想法是线圈内的东东所在的位置上下左右都存在0,然后四个方向遍历,确定它是否在圈内#include #include #include using namespace std;const int N=1445;int原创 2013-06-19 21:03:09 · 735 阅读 · 0 评论 -
hdu 4528 捉迷藏
http://acm.hdu.edu.cn/showproblem.php?pid=4528分析:其中一个人被发现后还会在原来的位置,用vis[x][y][4]数组保存查找状态(可以重复走同一位置):0)未发现任何人;1)只发现大明;2)只发现二明;3)都找到#include#include#include#includeusing namespace std;co原创 2013-09-24 14:19:19 · 487 阅读 · 0 评论 -
hdu 4427 玩转十滴水
http://acm.hdu.edu.cn/showproblem.php?pid=4527#include #include #include #include using namespace std;const int NM=10;struct Node{ int x,y,dir;};int c[4][2]={-1,0,1,0,0,-1,0,1};int a[N原创 2013-09-26 15:27:37 · 690 阅读 · 0 评论 -
【DFS】hdu 2181 哈密顿绕行世界问题
http://acm.hdu.edu.cn/showproblem.php?pid=2181分析:没啥说的,直接暴搜#include#includeusing namespace std;const int NM=25;int a[NM][NM],save[NM],vis[NM];int m,count;void DFS(int num,int city){ int i原创 2013-08-14 21:40:29 · 561 阅读 · 0 评论