https://ac.nowcoder.com/acm/contest/890/H
签到题:就是说了一大段废话。。。然后类似于化学 给你6个点构成的一个图 问你是哪一种

一共5种 建立一个无向图 统计度数 第一个度数全是2
第2 3个特判 第四个2个度数为3
第五个有一个度数为4
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<ctime>
#include<map>
#include<stack>
#include<queue>
#include<set>
#include<cstring>
#include<unordered_map>
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double ld;
const ll maxn = 1e12;
int du[10];
vector<int> g[10];
int main()
{
int T;
cin >> T;
while (T--)
{
for (int i = 1; i <= 6; i++)du[i] = 0;
for (int i = 1; i <= 6; i++)g[i].clear();
for (int i = 1; i < 6; i++)
{
int x, y;
scanf("%d%d", &x, &y);
du[x]++;
du[y]++;
g[x].push_back(y);
g[y].push_back(x);
}
static int cnt[10];
for (int i = 1; i <= 4; i++)cnt[i] = 0;
for (int i = 1; i <= 6; i++)cnt[du[i]]++;//统计每个点度数
if (cnt[4])puts("2,2-dimethylbutane");//有一个度数为4的点
else if (cnt[3] == 2)puts("2,3-dimethylbutane");//有2个度数为3的点
else if (cnt[3] == 0)puts("n-hexane");//只有度数为2的点
else
{
int p = 0;//寻找那个度数为3的点
for (int i = 1; i <= 6; i++)
if (du[i] == 3) {
p = i;
break;
}
int dd = 0;//与这个点相连的点的度数
for (auto t : g[p])dd += du[t];
if (dd == 4)puts("2-methylpentane");//度数为4
else puts("3-methylpentane");
}
}
return 0;
}







Comments | NOTHING