C. [STSC OI - 1C] 二叉树 (binary)

    传统题 555ms 256MiB

[STSC OI - 1C] 二叉树 (binary)

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Description

Given the preorder and inorder traversal sequences of a binary tree, output its postorder traversal.

Input

The input consists of two lines.

Line 11: The preorder traversal of the binary tree.

Line 22: The inorder traversal of the binary tree.

Output

Output one line containing the postorder traversal of the binary tree.

ABCD
CBAD
CBDA

Hint

For 100%100\% of the test cases, the input string length 11 \le is 20\le 20, containing only uppercase letters.

The data guarantees a valid solution.

【Sample #1 Explanation】

The binary tree structure is as follows:

      A
     / \
    B   D
   /
  C

超绝骗分赛

未参加
状态
已结束
规则
IOI
题目
4
开始于
2026-6-25 12:00
结束于
2026-6-29 12:00
持续时间
96 小时
主持人
参赛人数
6