AtCoder Beginner Contest 167
翻译中…
Problem Statement
翻译中…
A bracket sequence is a string that is one of the following:
翻译中…
- An empty string;
- The concatenation of
(,$A$, and)in this order, for some bracket sequence$A$; - The concatenation of
$A$and$B$in this order, for some non-empty bracket sequences$A$and$B$/
翻译中…
Given are $N$ strings $S_i$. Can a bracket sequence be formed by concatenating all the $N$ strings in some order?
翻译中…
Constraints
翻译中…
$1 \leq N \leq 10^6$- The total length of the strings
$S_i$is at most$10^6$. $S_i$is a non-empty string consisting of(and).
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
S_1
:
S_N
翻译中…
Output
翻译中…
If a bracket sequence can be formed by concatenating all the $N$ strings in some order, print Yes; otherwise, print No.
翻译中…
样例
Input #1
2
)
(()
Output #1
Yes
Concatenating `(()` and `)` in this order forms a bracket sequence.
Input #2
2
)(
()
Output #2
No
Input #3
4
((()))
((((((
))))))
()()()
Output #3
Yes
Input #4
3
(((
)
)
Output #4
No
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。