아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Date

시간 제한1초메모리 제한1024 MB

요약
숫자와 슬래시로 이루어진 문자열에서 앞에 0이 없는 y/m/d 형태의 올바른 날짜가 되는 부분수열의 개수를 10^9+7로 나눈 나머지로 구한다.
난이도

보통10점 중 6점

유형
동적 계획법, 문자열, 구현
정답자
아직 제출이 없습니다

문제

Fujiwara-san loves dates! She calls a date a string of form y/m/dy/m/d where dd, mm and yy are positive integers without leading zeroes that represent a calendar date (dd is the day, mm is the month, yy is the year). The precise rules for a valid date is the following:

  • y∈1,2,…y ∈ \\{1, 2, \dots\\}.
  • m∈1,…,12m ∈ \\{1, \dots , 12\\}.
  • If m∈1,3,5,7,8,10,12m ∈ \\{1, 3, 5, 7, 8, 10, 12\\}, then d∈1,…,31d ∈ \\{1, \dots , 31\\}.
  • If m∈4,6,9,11m ∈ \\{4, 6, 9, 11\\}, then d∈1,…,30d ∈ \\{1, \dots , 30\\}.
  • If m=2m = 2 and yy is either a not a multiple of 44, or both a multiple of 100100 and not a multiple of 400400, then d∈1,…,28d ∈ \\{1, \dots , 28\\}.
  • If m=2m = 2 and yy is a multiple of 44, and either not a multiple of 100100 or a multiple of 400400, then d∈1,…,29d ∈ \\{1, \dots , 29\\}.

For example, 2022/2/142022/2/14, 2024/2/292024/2/29 and 2000/2/292000/2/29 are valid dates; whereas 2022/02/142022/02/14, 2022/2/292022/2/29 and 2100/2/292100/2/29 are not valid dates.

Fujiwara-san has recently received a sequence of symbols s_1,…,s_ns\_1, \dots , s\_n, where s_i∈0,1,…,9,/s\_i ∈ \\{0, 1, \dots , 9, /\\}. She now wants to ask: how many sequences of indices 1≤i_1<⋯<i_k≤n1 ≤ i\_1 < \dots < i\_k ≤ n exist such that s_i_1,…,s_i_ks\_{i\_1} , \dots , s\_{i\_k} are a valid date?

입력

The first line of the input contains the integer nn. The second line contains the symbols s_1,…,s_ns\_1, \dots , s\_n, not separated by spaces.

출력

Output the answer modulo 109+710^9 + 7.

제한

  • 1≤n≤100,0001 ≤ n ≤ 100\\,000.

예제4

  1. 예제 1

    입력
    8
    55/55/55
    
    예상 출력
    12
    
  2. 예제 2

    입력
    7
    44/2/29
    
    예상 출력
    9
    
  3. 예제 3

    입력
    8
    11/11/31
    
    예상 출력
    24
    
  4. 예제 4

    입력
    22
    11/2/43432/534/123/234
    
    예상 출력
    66078