标签:c++ tput const scan [1] 结束 mem tar nbsp
http://acm.hdu.edu.cn/showproblem.php?pid=1181
#include <bits/stdc++.h> using namespace std; const int maxn = 30; int g[maxn][maxn]; char s[100000]; int len; /* g[i][j] == 0 (i -> j 走不通) g[i][j] == 1 (i -> j 可以走) */ void bfs() { int flag[30]; for(int i = 0; i < 26; i ++) { flag[i] = 0; } queue<int> Q; Q.push(1); flag[1] = 1; while(!Q.empty()) { int t = Q.front(); Q.pop(); for(int i = 0; i < 26; i ++) { if(g[t][i] && flag[i] == 0) { Q.push(i); flag[i] = 1; } } } if(flag[‘m‘ - ‘a‘]) { printf("Yes.\n"); } else { printf("No.\n"); } } int main() { while(~scanf("%s", s)) { len = strlen(s); if(len == 1 && s[0] == ‘0‘) { bfs(); memset(g, 0, sizeof g); continue; } g[s[0] - ‘a‘][s[len - 1] - ‘a‘] = 1; } return 0; }
标签:c++ tput const scan [1] 结束 mem tar nbsp
原文地址:https://www.cnblogs.com/zlrrrr/p/9465149.html