上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 27 下一页
摘要: 这是一个双向搜索题,我用BFS把所有的点都搜索到;再进行两次搜索的比较;#include<cstdio>#include<cstring>#include<iostream>using namespace std;class Node{public: int x , y ; int step; int num; };Node queue[80024];int step[2][204][204],N,M;int d[4][2] = { 0,1,1,0,-1,0,0,-1 };char map[204][204];int BFS( int x1,int y1, 阅读全文
posted @ 2012-03-02 14:51 wutaoKeen 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 这题是记忆化搜索:#include<iostream>#include<cstdio>#include<cstring>using namespace std;int map[124][124];int ans[124][124];int N,M;int DFS( int x ,int y ){ int sum = 0; if( x == N && y == M ) return 1; if( ans[x][y]>=0 ) return ans[x][y]; for( int i=0; i<= map[x][y] ; i++ ) 阅读全文
posted @ 2012-03-01 18:51 wutaoKeen 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 刚开始用暴搜一直RE了,后来加了一个标记就是把字符串转化成数字,如果出现过就标记它;有一组测试数据就是1111与5555是16;#include<iostream>#include<cstdio>#include<cstring>using namespace std;class Node{public: int step; char c[6]; Node() { memset( c , 0, sizeof( c ) ); } };char num1[6],num2[6];Node queue[10024];bool hash[10000];bool pus 阅读全文
posted @ 2012-03-01 16:44 wutaoKeen 阅读(394) 评论(0) 推荐(0) 编辑
摘要: 简单的搜索题:#include<iostream>#include<cstdio>#include<cstring>using namespace std;int flag,Count,step;char map[15][15];int STEP[15][15];bool hash[15][15];void DFS( int x, int y, int cnt ){ if( hash[x][y] ) {// flag =2; Count = cnt - STEP[x][y]; step = STEP[x][y... 阅读全文
posted @ 2012-03-01 13:07 wutaoKeen 阅读(120) 评论(0) 推荐(0) 编辑
摘要: 编辑器加载中... 阅读全文
posted @ 2012-02-29 21:22 wutaoKeen 阅读(115) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>#include<cstring>using namespace std;int num,hash[14],flag[14]={0};void DFS( int cnt,int n ){ if( cnt == n+1 ) { num++; return ; } for( int i = 1; i<= n ; i++ ) { if( !flag[i] ) { hash[cnt]=i; int Flag = 0;... 阅读全文
posted @ 2012-02-29 20:18 wutaoKeen 阅读(166) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>using namespace std;int num[1024],flag,save[1024],number,N;void DFS( int n, int sum ,int cnt){ if( sum == number ) { flag = 1; for( int i = 0; i< cnt ; i++ ) { printf( i==0?"%d":"+%d",save[i] ); } puts( "" ); ret... 阅读全文
posted @ 2012-02-29 20:16 wutaoKeen 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 简单搜索题:#include<iostream>#include<cstdio>#include<cstring>using namespace std;class Node{public: int x,y;};Node queue[424];int d[4][2]={0,-1,1,0,0,1,-1,0};char map[24][24];int BFS( int x, int y ){ int end =0 ,first = 0; Node t; t.x = x; t.y = y; queue[end]=t; end++; while( first < 阅读全文
posted @ 2012-02-28 22:20 wutaoKeen 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 该题用到二分的方法:#include<iostream>#include<algorithm>#include<cstdio>using namespace std;class Node{public: int h,w; };bool cmp( Node a ,Node b ){ if( a.w == b.w ) return a.h > b.h; return a.w < b.w; }Node doll[20024];int Doll( int n ){ int sum=0; int hash[20024]={0}; for( int i = 阅读全文
posted @ 2012-02-28 20:50 wutaoKeen 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 该题用广搜比较好,这里要处理好就是X*2的时候,我们知道如果一步一步地走也就最多终点与起点相减的绝对值,那么我们就不能超过终点加上他们的绝对值;#include<iostream>#include<cstdio>#include<cstring>using namespace std;class Node{public: int time,number;};Node queue[200024];int BFS( int A, int B ){ bool hash[200024]={0}; int dis = abs( A - B ); int first=0 阅读全文
posted @ 2012-02-28 19:38 wutaoKeen 阅读(164) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 27 下一页