CF776A.A Serial Killer
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Our beloved detective, Sherlock is currently trying to catch a serial killer who kills a person each day. Using his powers of deduction, he came to know that the killer has a strategy for selecting his next victim.
The killer starts with two potential victims on his first day, selects one of these two, kills selected victim and replaces him with a new person. He repeats this procedure each day. This way, each day he has two potential victims to choose from. Sherlock knows the initial two potential victims. Also, he knows the murder that happened on a particular day and the new person who replaced this victim.
You need to help him get all the pairs of potential victims at each day so that Sherlock can observe some pattern.
我们敬爱的侦探夏洛克目前正在追捕一名连环杀手,该杀手每天杀害一人。凭借其强大的推理能力,夏洛克得知该杀手在选择下一个受害者时遵循某种策略。
杀手在第一天从两名潜在受害者开始,从中选择一人将其杀害,并用一名新人替换该受害者。此后每天重复此过程。因此,每一天杀手都恰好有两名潜在受害者可供选择。夏洛克已知最初的两名潜在受害者;此外,他还知道某一天发生的谋杀案(即当天被杀害的受害者)以及替代该受害者的新人。
你需要帮助夏洛克推算出每一天的两名潜在受害者组成的有序对,以便他能从中发现某种规律。
输入格式
First line of input contains two names (length of each of them doesn't exceed 10), the two initials potential victims. Next line contains integer n (1 ≤ n ≤ 1000), the number of days.
Next n lines contains two names (length of each of them doesn't exceed 10), first being the person murdered on this day and the second being the one who replaced that person.
The input format is consistent, that is, a person murdered is guaranteed to be from the two potential victims at that time. Also, all the names are guaranteed to be distinct and consists of lowercase English letters.
输入的第一行包含两个姓名(每个姓名长度不超过 10),表示两名潜在受害者。
第二行包含一个整数 $ n ( 1 \leq n \leq 1000 $),表示天数。
接下来的 $ n $ 行,每行包含两个姓名(每个姓名长度不超过 10),第一个姓名表示当天被杀害的人,第二个姓名表示接替该位置的人。
输入格式是统一的,即:被杀害的人必定是当天的两名潜在受害者之一。此外,所有姓名均保证互不相同,且仅由小写英文字母组成。
输出格式
Output n + 1 lines, the i-th line should contain the two persons from which the killer selects for the i-th murder. The (n + 1)-th line should contain the two persons from which the next victim is selected. In each line, the two names can be printed in any order.
输出 n+1 行,第 i 行应包含杀手在第 i 次行凶时所选择的两个人。第 (n+1) 行应包含下一位受害者将从中选出的两个人。每行中的两个姓名可以以任意顺序输出。
输入输出样例
输入#1
ross rachel 4 ross joey rachel phoebe phoebe monica monica chandler
输出#1
ross rachel joey rachel joey phoebe joey monica joey chandler
输入#2
icm codeforces 1 codeforces technex
输出#2
icm codeforces icm technex
说明/提示
In first example, the killer starts with ross and rachel.
- After day 1, ross is killed and joey appears.
- After day 2, rachel is killed and phoebe appears.
- After day 3, phoebe is killed and monica appears.
- After day 4, monica is killed and chandler appears.
在第一个例子中,杀手从罗斯和瑞秋开始。
- 第 1 天后,罗斯被杀死,乔伊出现。
- 第 2 天后,瑞秋被杀死,菲比出现。
- 第 3 天后,菲比被杀死,莫妮卡出现。
- 第 4 天后,莫妮卡被杀死,钱德勒出现。
输入解题思路,AI测评打分。不知道怎么写?