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

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

Clubbing

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

요약
동아리 명단과 상담 일정이 주어질 때, 적어도 한 동아리의 모든 구성원이 등장하는 일정의 부분 문자열 개수를 센다.
난이도

보통10점 중 7점

유형
슬라이딩 윈도우, 투 포인터, 비트 연산
정답자
아직 제출이 없습니다

문제

Students of Tomorrow Programming School engage in different school programming clubs. Each student is a member of some number of clubs. The clubs are supervised by the Principal Club Coach (PCC). His main occupation is to talk to club members to help them organize their activities. PCC has a fixed schedule in the form of a list of students he is going to talk to in the nearest future. He always talks to only one student at a time, he may talk to a student repeatedly at various times. Each talk takes short time interval, which is always the same. There is negligible time between subsequent talks.

Currently, the school director also needs to talk to some students in the presence of PCC, because he needs to start another state supported programming project. He is going to visit PCC’s cabinet and spend some uninterrupted time there. In that time, he wants to talk to all members of at least one club. Thus, PCC defined a so-called director interval in his schedule. It is an uninterrupted sequence of his talks to students, in which all members of at least one club appear at least once.

Before he suggests an acceptable director interval, PCC at least wants to know the number of such intervals in his schedule.

입력

The first input line contains one integer N (1 ≤ N ≤ 105), the number of student clubs. Next N lines contain the list of club members, each line specifies one club. One club is specified by a string without spaces, in which each member is represented by a single character. All characters in the string are different. The last input line contains the schedule of PCC, in the form of nonempty string with at most 105 characters, each character represents one student. In all strings, each character is one of the first 17 lowercase letters in the alphabet(“a” - “q”).

출력

Output one integer, the number of director intervals in PCC’s schedule.

예제2

  1. 예제 1

    입력
    2
    pid
    lid
    lidp
    
    예상 출력
    3
    
  2. 예제 2

    입력
    2
    baf
    lek
    affleck
    
    예상 출력
    4