QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 64 MB مجموع النقاط: 100

#2497. 镜像括号

الإحصائيات

首先,让我们回顾一下什么是合法括号序列(CBS):

  • 空字符串是 CBS。
  • 如果 $s$ 是 CBS,那么 $(s)$ 和 $[s]$ 也是 CBS。
  • 如果 $s$ 和 $t$ 是 CBS,那么 $st$ 也是 CBS。
  • 如果一个序列不能通过上述规则得到,则它不是 CBS。

Vasya 写下了一个由括号 “(”、“)”、“[” 和 “]” 组成的合法括号序列。之后,Vasya 在序列的某些位置添加了字符 “b”、“d”、“o”、“p”、“q” 和 “x”。最终,Vasya 得到了一个字符串 $z$。

现在,Vasya 执行以下操作: 如果 $z$ 包含形如 $(t)$ 的子串(其中 $t$ 不包含括号),Vasya 会将其替换为 $t$ 字符串关于垂直轴的镜像反射。如果 $z$ 包含形如 $[t]$ 的子串(同样,$t$ 中不包含括号),Vasya 会将其替换为 $t$ 字符串关于水平轴的镜像反射。例如,子串 “(qbpoxd)” 将被替换为 “bxoqdp”,而子串 “[qbpoxd]” 将被替换为 “dpboxq”。

Vasya 重复执行这些操作,直到字符串中不再包含任何括号。 请根据给定的字符串 $z$,计算 Vasya 最终得到的字符串。

输入格式

输入仅包含一行字符串 $z$,其长度不超过 $10^5$,由字符 “(”、“)”、“[”、“]”、“b”、“d”、“o”、“p”、“q” 和 “x” 组成。保证 $z$ 中的所有括号构成一个合法括号序列。同时保证输入数据中至少包含一个字母。

输出格式

输出 Vasya 最终得到的字符串。

样例

样例输入 1

(qbpoxd)[qbpoxd]

样例输出 1

bxoqdpdpboxq

样例输入 2

d[xd(bx)op]q()[]xx

样例输出 2

dxqxqobqxx

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.