标签:rmi unsigned dfs lib void signed turn pre mouse
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 22248 Accepted Submission(s): 8035
#include<iostream> #include<cstdio> #include<cmath> #include<map> #include<cstdlib> #include<vector> #include<set> #include<queue> #include<cstring> #include<string.h> #include<algorithm> #define INF 0x3f3f3f3f typedef long long ll; typedef unsigned long long LL; using namespace std; const int N = 1e6+10; const ll mod = 1e9+7; int t=0,flag=0; struct Node { char head,next; }c[10000]; int vis[10000]; void DFS(char ch) { if(ch==‘m‘){ flag=1; return; } for(int i=0;i<t;i++) { if(vis[i]) continue; if(c[i].head==ch){ vis[i] = 1; DFS(c[i].next); vis[i]=0; } } } int main() { char s[100]; int i; while(~scanf("%s",s)) { if(s[0]==‘0‘)continue; t=0; int len=strlen(s); c[t].head=s[0]; c[t].next=s[len-1]; t++; while(scanf("%s",s),strcmp(s,"0")) { len=strlen(s); c[t].head=s[0]; c[t].next=s[len-1]; t++; } flag=0; for(int i=0;i<t;i++) { if(c[i].head == ‘b‘) { memset(vis,0,sizeof(vis)); vis[i] = 1; DFS(c[i].next); } if(flag) break; } if(flag) printf("Yes.\n"); else printf("No.\n"); } return 0; }
标签:rmi unsigned dfs lib void signed turn pre mouse
原文地址:http://www.cnblogs.com/Aa1039510121/p/6103191.html