QOJ.ac

QOJ

Limite de temps : 3 s Limite de mémoire : 2048 MB Points totaux : 100

#823. 平衡括号

Statistiques

在编程时,我们经常使用圆括号 ()、方括号 [] 和花括号 {}。有时,我们会不小心遗漏或多写一个括号。许多现代编程环境会自动检查这些字符集是否“平衡”,以节省调试时间。如果对于每一对开括号 (,都有一个与之匹配的闭括号 ),且方括号和花括号也遵循同样的规则,那么这组括号就被称为“平衡”的。配对字符之间的所有内容也必须递归地构成一个平衡字符串。例如,以下括号组合是平衡的:

([{}]) (){}[()] ((()()())(()))

而以下组合则不是:

(())( [(]) {}()[()]}

你的任务是编写一个程序,检查给定的括号组合是否平衡。

输入格式

输入包含一个数字 $n$($1 \le n \le 1000$),随后有 $n$ 行。每一行包含一个仅由字符 ()[]{} 组成的字符串。每个字符串的长度不超过 $1000$ 个字符。

输出格式

输出 $n$ 行。如果对应的括号组合是平衡的,则在每一行输出 “Balanced”;如果不是,则输出 “Not Balanced”。

样例

输入 1

6
([{}])
(){}[()]
((()()())(()))
(())(
[(])
{}()[()]}

输出 1

Balanced
Balanced
Balanced
Not Balanced
Not Balanced
Not Balanced

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.