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

17050번 - Parametriziran 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 512 MB33171356.522%

문제

A string of characters consisting of lowercase letters of the English alphabet and question marks is called a parameterized word (e.g., a??cd, bcd, ??). Two parameterized words are considered similar if the question mark symbols in both words can be replaced by arbitrary lowercase letters of the english alphabet so that the resulting strings are the same. For example, parameterized words a??? and ?b?a are similar because by replacing the question marks in both words it is possible to obtain the word abba.

Mirko has recently bought a collection of parametrized words. Among the N words found in the collection, Mirko is interested in how many pairs of similar parameterized words exist. All the words in the collection have the same number of characters, M, and it is possible that a word occurs multiple times in the collection.

입력

The first line contains the integer numbers N (1 ≤ N ≤ 50 000) and M (1 ≤ M ≤ 6).

Each of the following N lines contains one parameterized word from the collection with exactly M characters.

출력

Print the total number of similar pairs of parameterized words.

제한

예제 입력 1

3 3
??b
c??
c?c

예제 출력 1

2

Pairs of similar words are: (??b, c??) and (c??, c?c).

예제 입력 2

4 6
ab??c?
??kll?
a?k??c
?bcd??

예제 출력 2

3

예제 입력 3

5 2
??
b?
c?
?g
cg

예제 출력 3

8

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2018/2019 > Contest #5 4번

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

출처

대학교 대회

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

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