标签:
so soon river goes them got moon begin big 0
Yes.Harry 可以念这个咒语:"big-got-them".HintHint
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <queue> using namespace std; string str[1100]; bool vis[1100]; int ans, flag; void dfs(int pos){ int len = str[pos].length(); if(str[pos][len - 1] == 'm'){ flag = 1; return ; } for(int i = 0; i < ans; ++i){ if(str[pos][len - 1] == str[i][0] && !vis[i]){ vis[i] = 1; dfs(i); } } } int main (){ string s; ans = 0; flag = 0; while(cin >> s){ if(s[0] == '0'){ for(int i = 0; i < ans; ++i) if(str[i][0] == 'b') dfs(i); if(flag) printf("Yes.\n"); else printf("No.\n"); flag = 0; ans = 0; } else { str[ans++] = s; } } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/hpuhjh/article/details/47279677