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

19608번 - Searching for Strings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB8031719917.710%

문제

You’re given a string N, called the needle, and a string H, called the haystack, both of which contain only lowercase letters “a”..“z”.

Write a program to count the number of distinct permutations of N which appear as a substring of H at least once. Note that N can have anywhere between 1 and |N|! distinct permutations in total – for example, the string “aab” has 3 distinct permutations (“aab”, “aba”, and “baa”).

입력

The first line contains N (1 ≤ |N| ≤ 200 000), the needle string.

The second line contains H (1 ≤ |H| ≤ 200 000), the haystack string.

출력

Output consists of one integer, the number of distinct permutations of N which appear as a substring of H.

제한

예제 입력 1

aab
abacabaa

예제 출력 1

2

The permutations “aba” and “baa” each appear as substrings of H (the former appears twice), while the permutation “aab” does not appear.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2020 > CCC 2020 Senior Division 3번

  • 데이터를 추가한 사람: kcm1700
(追記) (追記ここまで)

출처

대학교 대회

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

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