#include "iostream"
#include "stdio.h"
#include "string"
using namespace std;
char num[260][260];
char fuwa[] = "BJHYN";
int main()
{
int TestCase, i, j, k, n, count, total, M, N;
cin >> TestCase;
while (TestCase--)
{
total = 0;
cin >> M >> N;
for (i = 0; i < M; i++)
scanf("%s", num[i]);
for (i = 0; i < M; i++)//第一行的比较
for (j = i + 1; j < M; j++)//第二行的比较
{
for (k = 0; k < 5; k++)//福娃的数目比较
{
count = 0;
for (n = 0; n < N; n++)//列中的比较
{
if (num[i][n] == fuwa[k] && num[j][n] == fuwa[k])
count++;
}
total += count * (count - 1) / 2;
}
}
cout << total << endl;
}
}
zoj 2975 Kinds of Fuwas
最新推荐文章于 2018-07-19 00:02:25 发布