【ICPC】2022银川站 E. Isomerism | 签到、模拟、化学(x)

262 阅读3分钟

本文已参与「新人创作礼」活动, 一起开启掘金创作之路。

【ICPC】2022银川站 E. Isomerism | 签到、模拟、化学(x)

题目链接

Problem - E - Codeforces

题目

image.png

  • If a carbon atom connects with two identical atoms or atomic groups, isomerism of the given ethylene derivative does not exist; otherwise
  • if some atoms or atomic groups connecting with carbon atoms are the same, the ethylene derivative is called Cis-Trans isomerism. If the two identical atoms or atomic groups lie on the same side (i.e. upside or downside in the figure above) of the carbon-carbon double bond, it is called Cis-isomerism, or else it is called Trans-isomerism;
  • if the four atoms or atomic groups connecting with carbon atoms are pairwise distinct, the ethylene derivative is called Zasammen-Entgegen isomerism. If the atom or the atomic group of R1 and R3 with a higher priority and the atom or the atomic group of R2 and R4 with a higher priority lie on the same side (i.e. upside or downside in the figure above) of the carbon-carbon double bond, it is called Zasamman-isomerism, or else it is called Entgegen-isomerism.

All the atoms or atomic groups which may appear in R1, R2, R3 and R4 are listed as follows in descending order of the priority, the first of which is the one with the highest priority.

  • -F, -Cl, -Br, -I, -CH3, -CH2CH3, -CH2CH2CH3, -H

Now, you are asked to determine if there is any isomerism for a given ethylene derivative and find out the naming method it fits for when possible.

题目大意

多组数据,每组数据包括四个字符串 R1,R2,R3,R4R_1,R_2,R_3,R_4,表示碳-碳双键周围的 4 个原子或原子团,不同的原子或原子团有着不同的优先度, R1,R2,R3,R4R_1,R_2,R_3,R_4 可能的取值按优先度从高到低有: -F-Cl-Br-I-CH3-CH2CH3-CH2CH2CH3-H

R1,R2,R3,R4R_1,R_2,R_3,R_4 的具有的性质我们应该输出对应的内容:

  • 如果一个碳原子与两个相同的原子或原子团相连,则输出 None
  • 如果两个相同的原子或原子团位于碳-碳双键的同一侧(即上图中的上侧或下侧),则输出 Cis
  • 如果两个相同的原子或原子团位于碳-碳双键的不同侧(即上图中一上一下),则输出 Trans
  • 如果 R1R_1R3R_3 中具有较高优先级的的原子或原子团与 R2R_2R4R_4 中具有较高优先级的的原子或原子团位于碳-碳双键的同一侧,则输出 Zasamman
  • 如果 R1R_1R3R_3 中具有较高优先级的的原子或原子团与 R2R_2R4R_4 中具有较高优先级的的原子或原子团位于碳-碳双键的不同侧,则输出 Entgegen

思路

rir_i 表示 RiR_i 的优先度(数字越小越优先),则按照题意:

  • R1=R3R_1=R_3 或者 R2=R4R_2=R_4,则输出 None
  • R1=R2R_1=R_2 或者 R3=R4R_3=R_4,则输出 Cis
  • R1=R4R_1=R_4 或者 R2=R3R_2=R_3,则输出 Trans
  • r1<r3r2<r4r_1<r_3\land r_2<r_4 或者 r1>r3r2>r4r_1>r_3\land r_2>r_4,则输出 Zasamman
  • 否则输出 Entgegen

代码

#include <bits/stdc++.h>

using namespace std;
const int N=1001;
map<string,int> rk;
int solve()
{
	string R1,R2,R3,R4;
	cin>>R1>>R2>>R3>>R4;
	int r1=rk[R1],r2=rk[R2],r3=rk[R3],r4=rk[R4];
	if (r1==r3||r2==r4) return 0;
	if (r1==r2||r3==r4) return 1;
	if (r1==r4||r2==r3) return 2;
	if (r1<r3&&r2<r4) return 3;
	if (r1>r3&&r2>r4) return 3;
	return 4;
}
int main() 
{
	int T;
	string ans[5];
	ans[0]="None";
	ans[1]="Cis";
	ans[2]="Trans";
	ans[3]="Zasamman";
	ans[4]="Entgegen";
	
	rk["-F"]=1;
	rk["-Cl"]=2;
	rk["-Br"]=3;
	rk["-I"]=4;
	rk["-CH3"]=5;
	rk["-CH2CH3"]=6;
	rk["-CH2CH2CH3"]=7;
	rk["-H"]=8;
	for (scanf("%d",&T);T--;)
		cout<<ans[solve()]<<"\n";
	return 0;
}