MicrosoftOA #53
Order Records by Matching Start and End
估计简单可在线判题
考点(AI 标注)哈希计数
Records (start,end,payload) form exactly one chain, in which the end of each record equals the start of the next. The input is shuffled; concatenate the payloads in chain order. Spaces in the content must be kept exactly as they are.
This site uses a standard input/output protocol.
输入格式
The first line contains N, and each record then takes two lines: start end, and the full payload. 1≤N≤200000; the source does not restrict the strings, so this site uses keys of 1..12 ASCII alphanumeric characters and payloads of 0..10 visible ASCII characters or spaces. All records are guaranteed to form exactly one chain with no cycles and no branches.
输出格式
Output the full concatenated content followed by a terminating newline; if the content is empty, output an empty line.
样例 1
输入:
3
aaa bbb
2
bbb ccc
1
ccc ddd
3
输出:
213
样例 2
输入:
1
p q
X
输出:
X
样例 3
输入:
2
b c
b
a b
a
输出:
ab
样例说明
Example 1: the chain aaa→bbb→ccc→ddd concatenates to 213. Example 2: the only record outputs X. Example 3: first a→b, then b→c, concatenating to " ab " with a leading and a trailing space.