05 2013 档案

摘要:记忆化搜索 1 #include<stdio.h> 2 #include<string.h> 3 int f[40][40][40]; 4 5 int ji(int a,int b,int c) 6 { 7 if(a<=0||b<=0||c<=0) 8 return 1; 9 10 if(f[a][b][c]>0)11 return f[a][b][c];12 13 else if(a>20||b>20||c>20)14 return f[a][b][c]=ji(20,20,20);15 16 else if(a<b&am 阅读全文
posted @ 2013-05-31 21:00 水门 阅读(294) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 char map[110][110],cpy[110][110]; 5 int vis[110][110]; 6 7 int dx[4]={0,0,1,-1}; 8 int dy[4]={1,-1,0,0}; 9 10 int tdx[8]={0,0,1,-1,1,-1,1,-1};11 int tdy[8]={1,-1,0,0,1,1,-1,-1};12 int n,i,j,cnt1,cnt2;13 14 void dfs(int i,int j)15 {16 int k;17 for(k=0; k=... 阅读全文
posted @ 2013-05-23 08:53 水门 阅读(122) 评论(0) 推荐(0)
摘要:也是以前做的一个题,当时不会。bfs: 1 #include<stdio.h> 2 #include<string.h> 3 int a,b,c; 4 int vis[55][55][55],map[55][55][55]; 5 6 int dx[6]={0,0,0,0,-1,1}; 7 int dy[6]={0,0,1,-1,0,0}; 8 int dz[6]={1,-1,0,0,0,0}; 9 struct node10 {11 int x,y,z;12 int time1;13 }pos,npos,queue[55*55*55];14 15 int bfs()16 阅读全文
posted @ 2013-05-23 08:41 水门 阅读(138) 评论(0) 推荐(0)
摘要:以前做过的一个题,今天又做了一次。 1 #include 2 #include 3 #define maxn 2000 4 5 int u[maxn],v[maxn],bin[maxn]; 6 int find(int x) 7 { 8 return bin[x]==x?x:(bin[x]=find(bin[x])); 9 };10 11 int main()12 {13 int n,m,i,sum,x,y;14 while(~scanf("%d",&n)&&n)15 {16 sum=n-1;17 scanf("%d",& 阅读全文
posted @ 2013-05-23 08:36 水门 阅读(174) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1025参考博客:http://www.felix021.com/blog/read.php?1587最长不下降子序列,有一种DP+二分的求法最长递增子序列 O(NlogN)算法View Code 1 #include<stdio.h> 2 #include<string.h> 3 int a[500001],d[500001]; 4 int find(int a,int left,int rig) 5 { 6 int mid; 7 while(left<=rig) 8 阅读全文
posted @ 2013-05-11 21:21 水门 阅读(192) 评论(0) 推荐(0)