随笔分类 -  ACM 搜索解题报告

poj 2965 BFS
摘要:状态压缩,记录路径 1 #include <iostream> 2 #include <string.h> 3 #include <stdio.h> 4 using namespace std; 5 const int maxx=100000; 6 char c[4][4]; 7 int que[maxx],cnt,step[maxx],n; 8 struct FF 9 { 10 int fa; 11 int path; 12 }; 13 FF father[maxx]; 14 int t[16]={63624,62532,61986,61713,36744 阅读全文

posted @ 2012-03-30 15:37 Inpeace7 阅读(166) 评论(0) 推荐(0)

poj 2488 DFS
摘要:水题,注意字典序输出 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 using namespace std; 5 const int maxx=50; 6 int dir[8][2]={{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}}; 7 int n,m,p1[maxx*maxx+2],p2[maxx*maxx+2],cnt; 8 bool visit[maxx+2][maxx+2]; 9 10 bool 阅读全文

posted @ 2012-03-29 15:20 Inpeace7 阅读(130) 评论(0) 推荐(0)

POJ 1111 DFS
摘要:DFS 水题求周长:若当前状态旁边有k个x,则总周长加4-x 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 using namespace std; 5 6 const int maxx=20; 7 int dir[8][2]={{0,-1},{1,0},{0,1},{-1,0},{1,-1},{1,1},{-1,1},{-1,-1}}; 8 int cnt,n,m; 9 char c[maxx+2][maxx+2];10 bool visit[maxx+2][maxx+ 阅读全文

posted @ 2012-03-29 10:52 Inpeace7 阅读(176) 评论(0) 推荐(0)

poj 2386 DFS
摘要:DFS 水题 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 using namespace std; 5 6 const int maxx=100; 7 int n,m,cnt,dir[8][2]={{0,-1},{1,-1},{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1}}; 8 char pool[maxx+2][maxx+2]; 9 bool visit[maxx+2][maxx+2];10 11 bool judge(int a,i 阅读全文

posted @ 2012-03-29 09:22 Inpeace7 阅读(121) 评论(0) 推荐(0)

poj 3620 DFS
摘要:水题 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 using namespace std; 5 6 const int maxx=100; 7 8 int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}}; 9 int n,m;10 bool wet[maxx+2][maxx+2],visit[maxx+2][maxx+2];11 int ans,cnt;12 struct A13 {14 int x,y;15 };16 A point[max 阅读全文

posted @ 2012-03-28 20:37 Inpeace7 阅读(150) 评论(0) 推荐(0)

hdu 2899 三分查找求极值
摘要:#include <iostream>#include <cmath>#include <stdio.h>using namespace std;#define eps 1e-6double f(double x,double y){ return 6.0*pow(x,7.0)+8.0*pow(x,6.0)+7.0*pow(x,3.0)+5.0*pow(x,2.0)-y*x;}int main(){ int t,tt; double sum,mid,tmid,l,r,y; freopen("in.txt","r",st 阅读全文

posted @ 2012-03-26 19:26 Inpeace7 阅读(165) 评论(0) 推荐(0)

导航