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

15393번 - Concerts 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.3 초 128 MB85444151.899%

문제

John enjoys listening to several bands, which we shall denote using A through Z. He wants to attend several concerts, so he sets out to learn their schedule for the upcoming season. He finds that in each of the following n days (n ≤ 105), there is exactly one concert. He decides to show up at exactly k concerts (k ≤ 300), in a given order, and he may decide to attend more than one concert of the same band.

However, some bands give more expensive concerts than others, so, after attending a concert given by band b, where b spans the letters A to Z, John decides to stay at home for at least hb days before attending any other concert.

Help John figure out how many ways are there in which he can schedule his attendance, in the desired order. Since this number can be very large, the result will be given modulo 109 + 7.

입력

The first line contains k and n. The second line contains the 26 hb values, separated by spaces. The third line contains the sequence of k bands whose concerts John wants to attend e.g., AFJAZ, meaning A, then F etc. The fourth line contains the schedule for the following n days, specified in an identical manner.

출력

The number of ways in which he can schedule his attendance (mod 109 + 7).

제한

예제 입력 1

2 10
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
AB
ABBBBABBBB

예제 출력 1

10

힌트

출처

ICPC > Regionals > Europe > Southeastern European Regional Contest > SEERC 2017 A번

  • 잘못된 조건을 찾은 사람: cki86201
(追記) (追記ここまで)

출처

대학교 대회

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

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