#include<algorithm> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<fstream> #define LL long long usingnamespace std; int v[10][10], vis[10], deep; voiddfs(int x, int len){ deep = max(len, deep); vis[x] = 1; for (int i = 1; i <= 6; i++) { if (v[x][i]) { if (!vis[i]) dfs(i, len + 1); } } vis[x] = 0; } voidbfs(){ int max_sum = 0, k = 0; for (int i = 1; i <= 6; i++) { int sum = 0; for (int j = 1; j <= 6; j++) { if (v[i][j]) { sum++; } } if (sum > max_sum) { max_sum = sum; k = i; } } // cout <<"sum:" <<max_sum<<endl; if (max_sum == 2) { cout << "n-hexane" << endl; return; } elseif (max_sum == 4) { cout << "2,2-dimethylbutane" << endl; return; } memset(vis, 0, sizeof(vis)); deep = 0; dfs(k, 0); if (deep == 3) { cout << "2-methylpentane" << endl; return; } max_sum = 0; for (int i = 1; i <= 6; i++) { int sum = 0; if (i == k) continue; for (int j = 1; j <= 6; j++) { if (v[i][j]) { sum++; } } if (sum > max_sum) { max_sum = sum; } } if (max_sum == 3) { cout << "2,3-dimethylbutane" << endl; return; } else { cout << "3-methylpentane" << endl; return; } }
intmain(){ int T; T = get_num(); while (T) { T--; memset(v, 0, sizeof(v)); for (int i = 1; i <= 5; i++) { int a, b; a = get_num(); b = get_num(); v[a][b] = v[b][a] = 1; } bfs(); } return0; }
South player: +---+---+---+---+---+---+---+---+---+---+---+---+---+ |6 6|A A|6 6|J J|5 5|6 6|7 7|9 9|4 4|5 5|7 7|9 9|T T| | C | C | D | D | S | S | S | S | H | H | H | H | H | |6 6|A A|6 6|J J|5 5|6 6|7 7|9 9|4 4|5 5|7 7|9 9|T T| +---+---+---+---+---+---+---+---+---+---+---+---+---+ West player: +---+---+---+---+---+---+---+---+---+---+---+---+---+ |2 2|5 5|9 9|K K|5 5|7 7|9 9|4 4|T T|J J|A A|8 8|A A| | C | C | C | C | D | D | D | S | S | S | S | H | H | |2 2|5 5|9 9|K K|5 5|7 7|9 9|4 4|T T|J J|A A|8 8|A A| +---+---+---+---+---+---+---+---+---+---+---+---+---+ North player: +---+---+---+---+---+---+---+---+---+---+---+---+---+ |3 3|4 4|J J|2 2|3 3|T T|Q Q|K K|8 8|Q Q|K K|2 2|3 3| | C | C | C | D | D | D | D | D | S | S | S | H | H | |3 3|4 4|J J|2 2|3 3|T T|Q Q|K K|8 8|Q Q|K K|2 2|3 3| +---+---+---+---+---+---+---+---+---+---+---+---+---+ East player: +---+---+---+---+---+---+---+---+---+---+---+---+---+ |7 7|8 8|T T|Q Q|4 4|8 8|A A|2 2|3 3|6 6|J J|Q Q|K K| | C | C | C | C | D | D | D | S | S | H | H | H | H | |7 7|8 8|T T|Q Q|4 4|8 8|A A|2 2|3 3|6 6|J J|Q Q|K K| +---+---+---+---+---+---+---+---+---+---+---+---+---+