diff --git a/POJ/1204_ACM_Ted.cpp b/POJ/1204_ACM_Ted.cpp new file mode 100644 index 0000000..ae09442 --- /dev/null +++ b/POJ/1204_ACM_Ted.cpp @@ -0,0 +1,70 @@ +#include +#include +using namespace std; +struct node +{ + node *next[26]; + int id; + node() + { + memset(next,0,sizeof(next)); + id=0; + } +}*head; +int dir[][2]={-1,0,-1,1,0,1,1,1,1,0,1,-1,0,-1,-1,-1};//方向 +char mat[1005][1005];//地图 +char s[1005]; +int out[1005][3]; +int cnt,x,y; +int n,m,w; +void build(char *s,node *head,int id)//建树 +{ + int len=strlen(s),k; + for(int i=0;inext[k]==NULL) + head->next[k]=new node(); + head=head->next[k]; + } + head->id=id; +} +void dfs(node *p,int a,int b,int c)//深搜 +{ + if(p==NULL) return; + if(p->id>0) + { + out[p->id][0]=x;out[p->id][1]=y;out[p->id][2]=c; + p->id=0; + //这里不能return + } + if(a<0||n<=a||b<0||m<=b) return; + dfs(p->next[mat[a][b]-'A'],a+dir[c][0],b+dir[c][1],c); +} +int main() +{ + head=new node(); + node *p; + scanf("%d%d%d",&n,&m,&w); + //输入地图 + for(int i=0;i