
搜索
凌阡陌
随心而为,我自逍遥
展开
-
poj1129
#include #include #include using namespace std;int n,ans;int mapp[30][30],color[30];bool Judge(int m,int r)//判断m是否与其相连接的点同色{ for(int j=0;j<n;j++) { if(mapp[m][j]&&color[j]==r)原创 2012-03-26 21:33:00 · 311 阅读 · 0 评论 -
东北赛题目及反思
这次参加东北赛真的很郁闷,虽然主办方提供了很好的环境,但不知道是发挥的不好,还是水平不够,只拿了三等奖,虽然是三等奖的前几名,但还是很郁闷。。。。。最重要的是合作问题,不知道为什么之前合作很愉快的团队,这次比赛合作的并不好,可能我占很大原因吧。。。。最先出的k题,很水的一个题,吕出的,一次就过,速度还不慢。接下来是我和张的一道题,我的那道题也很水,但是键盘一直不在我手上,所以出的不是很原创 2012-06-10 20:26:01 · 912 阅读 · 0 评论 -
省赛训练F 广搜
问题的模型是:在允许消耗一定量生命换取时间的前提下,从起始点到终点所需的最短时间。利用广度优先搜索,数组ti[i][j][k]:表示失去k点血量时,到达(i,j)的最快时间。由于开始有100点血,血量小于等于0时死亡,实际可用血量是99。使用优先队列,队列节点有三个属性:x,y,k,(x,y)为该节点表示的位置,k为失去的血量数.#include #include #include转载 2012-05-18 16:53:36 · 1873 阅读 · 0 评论 -
poj1101广搜
我的个神啊,怎么过都过不去,我都疯掉了!第一种是我觉得没有问题,但是怎么过不去的,烦请各位路过大神们帮忙看一下。第二种是一个特暴的广搜,都可以过去,无奈ing#include using namespace std;const int Pow2[4]={1,2,4,8};struct State{ int r,c;};int w,h;char board[78][78];原创 2012-04-18 21:05:23 · 613 阅读 · 0 评论 -
poj1010 枚举
/*枚举出所有情况,在枚举的过程中,选出最优解。大致题意:1、满足客户要求的即为可行解 2、种类最多即为最优解 3、在种类相同的情况下,张数少的更优 4、在张数相等的情况下,单个价值更大的更优 5、三者都相同,输出tie*/#include #include #include using namespace std;int stamp[1006];int s[4];int n,m,k,原创 2012-04-26 21:40:00 · 362 阅读 · 0 评论 -
poj1010搜索
问题重述: 给出n种邮票,每种邮票有自己的面值(面值可能重复) 指定m种“总面值”,对每种“总面值”,求解满足如下条件的组合以达到该“总面值”(1) 所用邮票在n种中可以重复选取(2) 所用邮票张数〈=4(3) 尽量多的使用那个不同种类的邮票 Max (Stamp Types)(4) 若转载 2012-04-25 20:35:06 · 334 阅读 · 0 评论 -
以hdu1241为例,区分dfs和bfs
#include #include using namespace std;const int maxn=110;char mapn[maxn][maxn];int m,n,count;int dir[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};void bfs(int a,int b){ m原创 2012-04-09 21:23:59 · 332 阅读 · 0 评论 -
poj1676模拟
#include using namespace std;const int LCD[10][9]={ {0,1,0,1,0,1,1,1,1}, {0,0,0,0,0,1,0,0,1}, {0,1,0,0,1,1,1,1,0}, {0,1,0,0,1,1,0,1,1}, {0,0,0,1,1,1,0,0,1}, {0,1,0,1,1,0,0,原创 2012-04-04 17:40:17 · 482 阅读 · 0 评论 -
poj1701
#include using namespace std;int t,m,a,b;int K[10001],sumK[10001];__int64 dD,c;int ans;int main(){ int i; cin>>t; while(t--) { cin>>m>>a>>b; cin>>K[1];c=sumK[1原创 2012-04-04 20:23:16 · 396 阅读 · 0 评论 -
hdu3368DFS
#include #include using namespace std;char s[10][10];int dir[8][2]={{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1},{1,0},{1,1}};void dfs(int x,int y,int d,int num,int &sum){ if(d==8)原创 2012-03-18 10:31:43 · 342 阅读 · 0 评论 -
hdu1045DFS+回溯
这是一道典型的DFS+回溯的题目,题目类似于皇后问题,但是多了限制条件,就是一行中可以有多个blockhouse,如果在他们之间有wall的话。代码如下:#include #include #include using namespace std;int mymap[5][5];int n,ans;int Judge(int a,int b)//判断在(a,b)之前原创 2012-03-16 21:29:14 · 249 阅读 · 0 评论 -
hdu1258 DFS+回溯
#include #include using namespace std;int tmp[15],a[15];int t,n;int flag;int dfs(int s,int index,int cnt){ if(s==t) { flag=1; printf("%d",tmp[0]); fo原创 2012-03-15 20:19:07 · 289 阅读 · 0 评论 -
hdu1016DFS+回溯
#include #include #include using namespace std;int prime[40]={0,0,1,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,1};int ans[100];int visit[100];int num;void原创 2012-03-14 16:26:02 · 281 阅读 · 0 评论 -
poj1426
#include #include using namespace std;int n;long long q[9999999];void bfs(){ int front,rear; front=rear=0; q[rear]=1; rear++; long long top; while(rear>front)原创 2012-03-12 21:29:53 · 247 阅读 · 0 评论 -
poj2907DFS
题意:在一个最大20*20的矩形中,有一个起点,和另外许多个点,求从这个点出发经过所有点,再回到起点最少经过多少步。因为只能上下左右地走,所以用到搜索。#include #include #include using namespace std;struct Node{ int x,y,flag;}node[100];int n,sx,sy;int ans,ret;v原创 2012-08-13 15:56:22 · 284 阅读 · 0 评论