QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 64 MB Total points: 110

#13586. 参数化

Statistics

由英文小写字母和问号组成的字符串被称为参数化单词(例如 a??cdbcd??)。如果两个参数化单词中的问号可以被替换为任意英文小写字母,使得替换后得到的字符串相同,则称这两个参数化单词是相似的。例如,参数化单词 a????b?a 是相似的,因为通过替换这两个单词中的问号,可以得到相同的单词 abba

Mirko 最近购买了一组参数化单词。在收集到的 $N$ 个单词中,Mirko 想知道存在多少对相似的参数化单词。集合中的所有单词都具有相同的长度 $M$,并且同一个单词可能会在集合中出现多次。

输入格式

第一行包含两个整数 $N$($1 \le N \le 50\,000$)和 $M$($1 \le M \le 6$)。

接下来的 $N$ 行,每行包含一个来自集合的参数化单词,长度恰好为 $M$。

输出格式

输出相似参数化单词对的总数。

子任务

  • 在占总分 30% 的测试数据中,满足 $M \le 2$。
  • 在另外占总分 30% 的测试数据中,满足 $M \le 4$。

样例

输入样例 1

3 3
??b
c??
c?c

输出样例 1

2

说明

第一组样例中,相似的单词对为:(??b, c??) 和 (c??, c?c)。

输入样例 2

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

输出样例 2

3

输入样例 3

5 2
??
b?
c?
?g
cg

输出样例 3

8

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.