2011年7月28日

摘要: #include <iostream> #include<cstdio> #include <queue> #include<string.h> using namespace std; const int N=210; bool mark[N][N]; char s[2*N],s1[N],s2[N]; int len,len1,len2,flag; void dfs(int i,int j,int k) { if (k>=len) {flag=true;return ;} if (mark[i][j]) return ; else mar 阅读全文
posted @ 2011-07-28 14:41 ljfbest 阅读(58) 评论(0) 推荐(0)
摘要: 讲的是一个小狗陷入一个迷宫,要求在指定的时间到达目的地,且不能走已经走过的路……本题也可以广搜,前面用广搜写了几道题,这次练练深搜吧...#include <iostream> #include<cstdio> #include <queue> #include<string.h> using namespace std; int n,m,t,si,sj,di,dj; char map[15][15]; bool flag; int dir[][2]={{0,1},{0,-1},{1,0},{-1,0}}; void dfs(int ii,int 阅读全文
posted @ 2011-07-28 11:09 ljfbest 阅读(67) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <string.h> char str[100000]; char str1[100000]; char str2[200000]; int next[100000]; void getNext(int m) { int i=1,j=0; while(i<m) { if(j==0||str1[i]==str1[j]) { i++,j++; if(str1[i]==str1[j]) next[i]=next... 阅读全文
posted @ 2011-07-28 09:08 ljfbest 阅读(86) 评论(0) 推荐(0)
摘要: 南阳理工NYOJ这是我们学校自己的oj 希望acmer观摩下;本题同上一篇文章一模一样……水池数目时间限制:3000ms | 内存限制:65535KB难度:4描述南阳理工学院校园里有一些小河和一些湖泊,现在,我们把它们通一看成水池,假设有一张我们学校的某处的地图,这个地图上仅标识了此处是否是水池,现在,你的任务来了,请用计算机算出该地图中共有几个水池。输入第一行输入一个整数N,表示共有N组测试数据每一组数据都是先输入该地图的行数m(0<m<100)与列数n(0<n<100),然后,输入接下来的m行每行输入n个数,表示此处有水还是没水(1表示此处是水池,0表示此处是地面) 阅读全文
posted @ 2011-07-28 08:37 ljfbest 阅读(105) 评论(0) 推荐(0)

2011年7月27日

摘要: 一道简单的搜索题,本题我用的是广搜写的,深搜当然也可以...#include <iostream> #include <queue> #include<string.h> using namespace std; int m,n; char map[105][105]; int dir[][2]={{0,1},{0,-1},{1,0},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}}; struct st { int x,y; st(int m=0,int n=0) { x=m;y=n; } }; void bfs(int x,int 阅读全文
posted @ 2011-07-27 19:40 ljfbest 阅读(90) 评论(0) 推荐(0)
摘要: #include <iostream> #include <queue> using namespace std; const int MAX = 99999999; int n,m; struct st { char cc; int num,x,y,prex,prey; }map[105][105]; int dir[4][2]={{-1,0},{0,-1},{1,0},{0,1}}; void outPut() { int x=0,y=0,a,b,num=1,i; if(map[0][0].num!= MAX) { printf("It takes %d 阅读全文
posted @ 2011-07-27 16:53 ljfbest 阅读(68) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <string.h> int N,M; int a[1000005],b[10005],next[10005]; void getnext() { int k=1,j=0; while(k<M) { if(j==0||b[j]==b[k]) { ++j;++k; if(b[j]==b[k]) next[k]=next[j]; else next[k]... 阅读全文
posted @ 2011-07-27 08:21 ljfbest 阅读(60) 评论(0) 推荐(0)

导航