【題目敘述】https://vjudge.net/problem/UVA-599
#include <iostream>
using namespace std;
int t, cnt[26], edges, nodes, acorn;
string s;
int main() {
cin >> t;
while (t--){
for (int i = 0; i < 26; i++){
cnt[i] = 0;
}
edges = 0;
nodes = 0;
acorn = 0;
while (1){
cin >> s;
if (s[0] == '*') break;
cnt[s[1]-'A']++;
cnt[s[3]-'A']++;
edges++;
}
cin >> s;
for (int i = 0; i < s.length(); i += 2){
nodes++;
if (cnt[s[i]-'A'] == 0) acorn++;
}
//cout << nodes << " " << edges << " " << acorn << "\n";
cout << "There are "<< nodes-edges-acorn << " tree(s) and " << acorn << " acorn(s).\n";
}
}