Codeforces Round 504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)
C
Bracket Subsequence
Codeforces
1200
原题
← BD →
翻译中…

A bracket sequence is a string containing only characters "(" and ")". A regular bracket sequence is a bracket sequence that can be transformed into a correct arithmetic expression by inserting characters "1" and "+" between the original characters of the sequence. For example, bracket sequences "()()" and "(())" are regular (the resulting expressions are: "(1)+(1)" and "((1+1)+1)"), and ")(", "(" and ")" are not.

翻译中…

Subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

翻译中…

You are given a regular bracket sequence $s$ and an integer number $k$. Your task is to find a regular bracket sequence of length exactly $k$ such that it is also a subsequence of $s$.

翻译中…

It is guaranteed that such sequence always exists.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $k$ ($2 \le k \le n \le 2 \cdot 10^5$, both $n$ and $k$ are even) — the length of $s$ and the length of the sequence you are asked to find.

翻译中…

The second line is a string $s$ — regular bracket sequence of length $n$.

翻译中…

Output

翻译中…

Print a single string — a regular bracket sequence of length exactly $k$ such that it is also a subsequence of $s$.

翻译中…

It is guaranteed that such sequence always exists.

翻译中…

样例

Input #1
6 4
()(())
Output #1
()()
InputCopy OutputCopy
Input #2
8 8
(()(()))
Output #2
(()(()))
InputCopy OutputCopy
题目信息
题号
1023C
时间限制
2 s
内存限制
256 MB
标签
贪心

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。