Logo
(追記) (追記ここまで)

28380번 - Loop Invariant 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB127736866.667%

문제

Luna, a historian, was exploring the archives of an old monastery when she stumbled on a mysterious scroll of parchment. On it were only two types of symbols: '(' and ')'. Soon she noticed that the sequence of symbols satisfies an interesting property: It can be constructed by repeatedly inserting '()' at some position into an initially empty sequence. Historians call such sequences balanced. Figure L.1 gives an example of a balanced sequence.

Figure L.1: Sample Input 2 derived by successively inserting '()' into an initially empty sequence.

The chief librarian of the monastery recently told Luna that some of the more elitist monks in the region had a habit of writing on circular pieces of parchment. In their minds, anyone incapable of immediately telling where the text on such a scroll started was also unworthy of knowing its content. Consequently, Luna quickly inspected the edges of her parchment strip. And sure enough, the edges at the left and right end of the parchment strip fit together perfectly, indicating that the parchment once actually was circular. While holding the left and right edges together and looking at the now circular parchment, she wonders whether the balanced sequence starting at the tear is the only such sequence that could have resulted from tearing the parchment apart. After all, it makes little sense trying to decrypt a text when you do not even know where it starts.

입력

The input consists of:

  • One line with a balanced sequence $s$ (2ドル\leq |s|\leq 10^6$), the sequence on Luna's strip of parchment.

출력

Output "no" if there is no way to obtain a different balanced sequence by cutting the circular sequence, otherwise give any such sequence.

제한

예제 입력 1

(()())(()())

예제 출력 1

no

예제 입력 2

()(())()

예제 출력 2

(())()()

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > German Collegiate Programming Contest > GCPC 2023 L번

  • 문제를 만든 사람: Michael Zündorf
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /