問題一覧 > 通常問題

No.2143 Only One Bracket

レベル : / AI推定難易度 : 925 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 129
作問者 : milkcoffee / テスター : nok0 cpbm_p
お気に入りにしたユーザー ProblemId : 8289 / 自分の提出
問題文最終更新日: 2022-11-25 22:34:51
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 370 (順位表) の他の問題:

Problem Statement

Find one tuple of $N$ strings $(S_1, S_2 , \dots , S_N)$ that satisfies all of the following conditions.

  • $S_i$ consists of (, ).
  • $|S_i| \geq 1$
  • $|S_1|+|S_2|+\dots + |S_N| \leq N^2$
  • There exists exactly $1$ permutation $P=(P_1, P_2, \dots, P_N)$ of $(1,2, \dots, N)$ that satisfies the following.
    • $S_{P_1} + S_{P_2} + \dots + S_{P_N}$ is a balanced bracket string.

Here, "$+$" on strings simply denotes string concatenation.

A balanced bracket string is defined as a string that satisfies one of the following conditions.

  • The empty string
  • A string obtained by concatenating $s,t$ in this order, where there exist non-empty balanced bracket strings $s,t$
  • A string obtained by concatenating (, $s$, ) in this order, where there exists a balanced bracket string $s$

Input

$N$

  • $2 \leq N \leq 8$
  • $N$ is an integer

Output

Print $S_i$ on the $i$-th line.
If there are multiple solutions satisfying the conditions, any of them will be accepted.

Sample

Sample 1
Input
2
Output
)
(()

When $P=(2,1)$, we have $S_{P_1}+S_{P_2}=$ (()), which is a balanced bracket string.
This is the only $1$ permutation $P$ for which $S_{P_1}+S_{P_2}$ is a balanced bracket string, so the last condition is satisfied.
The other conditions are also satisfied, so this output is accepted.

For example, if $S_1=$(), $S_2=$(), then the result is a balanced bracket string in $2$ cases, $S_1+S_2$ and $S_2+S_1$, so this would be judged incorrect.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。