05 2012 档案
POJ 3278
摘要:半小时就写完了代码,提交后,一直是wa,煎熬了两小时后发现,忘了考虑在同一点这一情况#include <stdio.h> #include <memory.h> const int maxn=200000+10; int N,K; int queue[maxn]; int visit[maxn]={0}; int dis[maxn]; int bfs(int N,int K) { int font=0; int rear=0; queue[rear++]=N; visit[N]=1; int tem; while(font<rear) { int w=queue[ 阅读全文
posted @ 2012-05-29 19:06 lishimin_come 阅读(98) 评论(0) 推荐(0)
POJ 3083
摘要:#include <stdio.h> #include <memory.h> const int maxn=40+10; int visit[maxn*maxn]; int map[maxn][maxn]; int m,n; int dir[4][2]={{0,-1},{-1,0},{0,1},{1,0}}; int step1; int step2; void dfs1(int step ,int way,int tem) { int x=tem/n; int y=tem%n; if(map[x][y]=='E'){ step1=step; retur 阅读全文
posted @ 2012-05-29 16:14 lishimin_come 阅读(149) 评论(0) 推荐(0)
POj 1105解题报告
摘要:路径模拟+dfs#include <stdio.h>const int maxn=128+10;char terminal[maxn];char outcome[maxn];int n;char order[8];int amount=0;char s[8][2];char dfs(int height,int loc){ if(height==n) return terminal[loc-1]; int a=s[height][1]-'0'; int b=order[a-1]-'0'; if(b==0) return(dfs(height+1,lo 阅读全文
posted @ 2012-05-27 15:00 lishimin_come 阅读(192) 评论(0) 推荐(0)
POj 1145
摘要:伤不起呀#include <stdio.h>int n;int flag;char inputFilter(){ char c; while(scanf("%c",&c)&&c==' '||c=='\n'||c==9||c==10); return c;}int dfs(int sum,int height){ char c; int sign=1; int count=0; c=inputFilter();//个人认为此处是本题的关键点1 if(c==')') return height; 阅读全文
posted @ 2012-05-26 18:30 lishimin_come 阅读(117) 评论(0) 推荐(0)
POJ 2243解题报告
摘要:BFS#include <stdio.h>#include <memory.h>#include <stdlib.h>const int maxn=15;int visit[maxn*maxn];int dir[8][2]={{-2,-1},{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2}};char a[3];char b[3];int bfs(int st,int fin);int main(){ while(scanf("%s",a)!=EOF) { scanf("%s&quo 阅读全文
posted @ 2012-05-22 19:46 lishimin_come 阅读(120) 评论(0) 推荐(0)
eoe·Android 开发门户 - android开发者的必备网站
摘要:点击打开链接 阅读全文
posted @ 2012-05-21 18:45 lishimin_come 阅读(131) 评论(0) 推荐(0)
POJ 1481
摘要:AC啦!!!此题用到了两个DFS,刚开始一直认为两个DFS是交叉的,一直是错。后来从最简单的方面考虑,它遍历它的,它遍历它的,最后搞出来啦。#include <stdio.h> #include <memory.h> #include <stdlib.h> const int maxn=50+10; char map[maxn][maxn]; int visit[maxn][maxn]; int visit2[maxn][maxn]; int total[maxn]; int amount=0; int m,n,flag; int count1; int d 阅读全文
posted @ 2012-05-21 18:37 lishimin_come 阅读(117) 评论(0) 推荐(0)
zoj 1002解题报告
摘要:第一道dfs,值得纪念#include <stdio.h> const int max=5; char map[max][max]; int visit[max][max]; int count,k,maxn,n; int judge(int x,int y) { int i,j; for(i=x,j=y-1;j>=0;j--) { if(visit[i][j]==1) return 0; else if(map[i][j]=='X') break; } for(j=y,i=x-1;i>=0;i--) { if(visit[i][j]==1) retur 阅读全文
posted @ 2012-05-18 23:23 lishimin_come 阅读(148) 评论(0) 推荐(0)
POJ 1214 解题报告
摘要:#include <iostream> #include <string> #include <stack> using namespace std; const int maxn=53; int mount; stack<string> s[maxn]; void stackInput(); void moveCard(); void finalOutput(); bool isMatch(string s1,string s2); int main() { string str; while(cin >> str,str!=&qu 阅读全文
posted @ 2012-05-18 20:49 lishimin_come 阅读(192) 评论(0) 推荐(0)
POJ 1562
摘要:此题不难,典型的DFS,但是却WN了N次。应为本题的测试数据m,n后可能有空格,所以把scanf("%c")改成scanf(“%S);#include <stdio.h> #include <memory.h> const int maxn=100+10; int m,n; int count; int visit[maxn][maxn]; char map[maxn][maxn]; void dfs(int x,int y); int dir[8][2]={{-1,-1},{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1} 阅读全文
posted @ 2012-05-18 20:47 lishimin_come 阅读(181) 评论(0) 推荐(0)