标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 19593 Accepted Submission(s): 7041
1 #include <iostream> 2 #include <string> 3 using namespace std; 4 5 bool m[26][26]; 6 7 int main() 8 { 9 string s; 10 char f,e; 11 while(cin>>s) 12 { 13 14 if(s!="0") 15 { 16 f=s[0]; 17 e=s[s.length()-1]; 18 m[f-‘a‘][e-‘a‘]=true; 19 } 20 else 21 { 22 for(int k=0;k<26;k++) 23 for(int i=0;i<26;i++) 24 if(m[i][k]) 25 { 26 for(int j=0;j<26;j++) 27 if(m[k][j]) 28 m[i][j]=true; 29 } 30 31 if(m[‘b‘-‘a‘][‘m‘-‘a‘]) 32 cout<<"Yes."<<endl; 33 else 34 cout<<"No."<<endl; 35 memset(m,0,sizeof(m)); 36 } 37 } 38 }
标签:
原文地址:http://www.cnblogs.com/cumulonimbus/p/5158788.html