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

5964번 - Best Parenthesis 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB3641067932.645%

문제

Recently, the cows have been competing with strings of balanced parentheses and comparing them with each other to see who has the best one.

Such strings are scored as follows (all strings are balanced): the string "()" has score 1; if "A" has score s(A) then "(A)" has score 2*s(A); and if "A" and "B" have scores s(A) and s(B), respectively, then "AB" has score s(A)+s(B). For example, s("(())()") = s("(())")+s("()") = 2*s("()")+1 = 2*1+1 = 3.

Bessie wants to beat all of her fellow cows, so she needs to calculate the score of some strings. Given a string of balanced parentheses of length N (2 <= N <= 100,000), help Bessie compute its score.

입력

  • Line 1: A single integer: N
  • Lines 2..N + 1: Line i+1 will contain 1 integer: 0 if the ith character of the string is '(', and 1 if the ith character of the string is ')'

출력

  • Line 1: The score of the string. Since this number can get quite large, output the score modulo 12345678910.

제한

예제 입력 1

6
0
0
1
1
0
1

예제 출력 1

3

힌트

This corresponds to the string "(())()".

출처

Olympiad > USA Computing Olympiad > 2010-2011 Season > USACO February 2011 Contest > Silver 2번

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

출처

대학교 대회

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

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