CF382A.Ksenia and Pan Scales
普及-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Ksenia has ordinary pan scales and several weights of an equal mass. Ksenia has already put some weights on the scales, while other weights are untouched. Ksenia is now wondering whether it is possible to put all the remaining weights on the scales so that the scales were in equilibrium.
The scales is in equilibrium if the total sum of weights on the left pan is equal to the total sum of weights on the right pan.
克谢尼娅有一架普通的天平和若干个质量相等的砝码。克谢尼娅已经将其中一些砝码放在了天平上,其余砝码尚未使用。现在克谢尼娅想知道:是否可以将所有剩余的砝码全部放置到天平上(可任意选择放在左盘或右盘),使得天平达到平衡。
当天平左盘上所有砝码的总质量等于右盘上所有砝码的总质量时,天平即处于平衡状态。
输入格式
The first line has a non-empty sequence of characters describing the scales. In this sequence, an uppercase English letter indicates a weight, and the symbol "|" indicates the delimiter (the character occurs in the sequence exactly once). All weights that are recorded in the sequence before the delimiter are initially on the left pan of the scale. All weights that are recorded in the sequence after the delimiter are initially on the right pan of the scale.
The second line contains a non-empty sequence containing uppercase English letters. Each letter indicates a weight which is not used yet.
It is guaranteed that all the English letters in the input data are different. It is guaranteed that the input does not contain any extra characters.
第一行包含一个非空的字符序列,用于描述天平。在此序列中,大写英文字母表示砝码,符号“|”表示分隔符(该字符在序列中恰好出现一次)。分隔符之前的所有砝码初始时均置于天平的左盘;分隔符之后的所有砝码初始时均置于天平的右盘。
第二行包含一个非空的字符序列,其中每个大写英文字母均表示一个尚未使用的砝码。
保证输入数据中的所有英文字母互不相同。保证输入中不包含任何额外字符。
输出格式
If you cannot put all the weights on the scales so that the scales were in equilibrium, print string "Impossible". Otherwise, print the description of the resulting scales, copy the format of the input.
If there are multiple answers, print any of them.
如果无法将所有砝码放在天平上使天平达到平衡,则输出字符串 "Impossible"。否则,输出平衡后天平的状态描述,格式与输入保持一致。
若存在多个可行解,输出任意一个即可。
输入输出样例
输入#1
AC|T L
输出#1
AC|TL
输入#2
|ABC XYZ
输出#2
XYZ|ABC
输入#3
W|T F
输出#3
Impossible
输入#4
ABC| D
输出#4
Impossible
输入解题思路,AI测评打分。不知道怎么写?