摘要: 本题哈希,但judge的时间还是很长,哎;#include <stdio.h>#include <memory.h>#define maxn 100003struct s{ int arms[6]; int amount;}snow[maxn];int head[maxn],next[maxn];//maxn大小的哈希表int judge(int *a,int *b){ int i,j,ok=1,t=0; int k[6]; for(i=0;i<6&&ok;i++) { for(j=0;j<6;j++) { if(a[i]==b[j]) { 阅读全文
posted @ 2012-06-07 20:29 lishimin_come 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 这道题用了两个多小时,调试了n次后发现是变量w的问题,得到的教训就是以后要改变量的值时要考虑改变了的变量值对后续的工作有没有影响。 阅读全文
posted @ 2012-06-02 17:10 lishimin_come 阅读(132) 评论(0) 推荐(0) 编辑
摘要: BFS+剪枝#include <stdio.h>#include <memory.h>int prime[10000];int st,fin;void Prime(){ int i,j; for(i=2;i<10000;i++) { if(!prime[i]) { for( j=i+i;j<10000;j+=i) { prime[j]=1; } } }}int getvalue(int a[]){ int m=0; for(int i=3;i>=0;i--) { m=m*10+a[i]; } return m;}int bfs(int st,int f 阅读全文
posted @ 2012-06-02 17:04 lishimin_come 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 半小时就写完了代码,提交后,一直是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 阅读(96) 评论(0) 推荐(0) 编辑
摘要: #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 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 路径模拟+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 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 伤不起呀#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 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 点击打开链接 阅读全文
posted @ 2012-05-21 18:45 lishimin_come 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 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 阅读(115) 评论(0) 推荐(0) 编辑