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

21053번 - Gig Combinatorics 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB1711008476.364%

문제

Your friend Tóti is an aspiring musician. He has written $n$ songs, each of which has a hype rating of either 1ドル,ドル 2ドル,ドル or 3ドル$. A higher hype rating means the song has more energy. Tóti is planning his first live performance and needs your help. He wants to know how many setlists he can make. A setlist consist of at least three songs, the first song must have hype rating 1ドル,ドル the last song must have hype rating 3ドル,ドル and all other songs must have hype rating 2ドル$. Tóti also wants to play the songs in the same order he wrote them.

Given the hype rating of each of Tóti's songs in the order he wrote them, how many setlists can he make?

입력

The first line of input consists of an integer $n$ (1ドル \leq n \leq 10^6$), the number of songs Tóti has written. The second line consists of $n$ integers, each in $\{1, 2, 3\},ドル giving the hype ratings of the $n$ songs in the order they were written.

출력

Output the number of setlists Tóti can make. Since this number can be large, print it modulo 10ドル^9 + 7$.

제한

예제 입력 1

9
1 1 1 2 2 2 3 3 3

예제 출력 1

63

예제 입력 2

8
1 2 1 2 3 1 2 3

예제 출력 2

15

힌트

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > Nordic Collegiate Programming Contest > NCPC 2020 G번

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 3: Nordic+ Contest 2020 G번

  • 문제를 만든 사람: Bergur Snorrason, Eyleifur Ingþór Bjarkason
(追記) (追記ここまで)

출처

대학교 대회

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

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