随笔分类 -  搜索

摘要:1 #include<stdio.h> 2 #include<string.h> 3 #include<set> 4 #include<time.h> 5 using namespace std; 6 7 typedef int state[9]; 8 const int max=1000000; 9 state st[max],goal;10 int dist[max];11 const int dx[]={-1,1,0,0};12 const int dy[]={0,0,-1,1};13 14 struct cmp15 {16 bool op 阅读全文
posted @ 2013-04-24 21:43 萧凡客 阅读(197) 评论(0) 推荐(0) 编辑
摘要:1 #include<stdio.h> 2 #include<string.h> 3 4 char a[7]; 5 char b[750][7]; 6 char c[6]={'A','B','C','D','E','*'}; 7 int t[4][2]={1,0,0,1,0,-1,-1,0}; 8 int temp; 9 10 int fun(char *p,int n,int m)11 {12 int i,j,x,y,u;13 char v[6],k;14 if(!(str 阅读全文
posted @ 2013-04-22 14:06 萧凡客 阅读(281) 评论(0) 推荐(0) 编辑
摘要:1 #include<stdio.h> 2 3 int n,l; 4 char s[100]; 5 6 int dfs(int cur) 7 { 8 int i,j,ok,equal,k; 9 if(cur==n)10 {11 for(i=0;i<n;i++)12 printf("%c",'A'+s[i]);13 printf("\n");14 return 0;15 }16 for(i=0;i<l;i++)17 {18 s[cur]=i;19 ... 阅读全文
posted @ 2013-04-03 22:25 萧凡客 阅读(274) 评论(0) 推荐(0) 编辑
摘要:1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 /*下面定义结点的类型*/ 5 #define Min(a,b) ((a>b)?b:a) 6 //宏定义的操作符Min作用 取最小值; 7 const int MAX=1010; 8 //解答树的结点最多 9 typedef struct Node 10 { 11 int v[3];//三个杯子的剩余水量; 12 int fa;//第一次访问到这个结点是的前一个结点的下标; 13 //通过下... 阅读全文
posted @ 2013-04-01 22:25 萧凡客 阅读(1908) 评论(0) 推荐(1) 编辑
摘要:(1)当n=1时,不论m的值为多少(m>0),只有一种划分即{1}; (2) 当m=1时,不论n的值为多少,只有一种划分即n个1,{1,1,1,...,1}; (3) 当n=m时,根据划分中是否包含n,可以分为两种情况: (a). 划分中包含n的情况,只有一个即{n}; (b). 划分中不包含n的情况,这时划分中最大的数字也一定比n小,即n的所有(n-1)划分。 因此 f(n,n) =1 + f(n,n-1); (4) 当n<m时,由于划分中不可能出现负数,因此就相当于f(n,n); (5) 但n>m时,根据划分中是否包含最大值m,可以分为两种情况: (a). 划分中包含m的 阅读全文
posted @ 2012-12-13 22:19 萧凡客 阅读(226) 评论(0) 推荐(0) 编辑
摘要:小希的迷宫Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 15635Accepted Submission(s): 4752Problem Description上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提 阅读全文
posted @ 2012-11-16 22:39 萧凡客 阅读(700) 评论(0) 推荐(0) 编辑
摘要:并查集常用代码 1 #include<stdio.h> 2 #define MAX 11 3 4 5 int father[MAX]; /* father[x]表示x的父节点*/ 6 int rank[MAX]; /* rank[x]表示x的秩*/ 7 8 9 /* 初始化集合*/10 void Make_Set(int x)11 {12 father[x] = x; //根据实际情况指定的父节点可变化13 rank[x] = 0; //根据实际情况初始化秩也有所变化14 }15 16 17 18 19 //查找父节点20 int find(int x)... 阅读全文
posted @ 2012-11-16 22:33 萧凡客 阅读(167) 评论(0) 推荐(0) 编辑
摘要:以北大的1979为例:Red and BlackTime Limit: 1000MSMemory Limit: 30000KTotal Submissions: 17144Accepted: 9025DescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move to one of four adjacent tiles. 阅读全文
posted @ 2012-08-22 19:08 萧凡客 阅读(2206) 评论(0) 推荐(1) 编辑