/*
1035. DNA matching简单题
题目大意:
给出n个DNA单链,问可以用这些DNA单链组成多少个DNA双链;
每个DNA单链最多使用一次;
两个DNA单链能组成DNA双链,当且仅当两个DNA单链的长度相等,且对应位置上能配对,A与T配对,C与G配对;
n<=100, 每个单链长度不超过100。
解题思路:
枚举每个没有被匹配的DNA单链,再枚举另外一个没有被匹配的DNA单链,如果它们能匹配,则都标记为匹配,答案加一。
for (i = 0; i < N; i++)
if (!vst[i])
for (j = i + 1; j < N; j++) if (!vst[j]) {
if (match(DNA[i], DNA[j])) {
ans++;
vst[i] = vst[j] = true;
break;
}
}
*/
#include <iostream>
#include <string>
using namespace std;
int main(){
int t;
int n;
int m;
string strand[100];
cin >> t;
for(int l=0;l<t;l++){
cin >>n;
m=0;
for(int i=0;i<n;i++){
cin >> strand[i];
}
for(int i=0;i<n;i++){
//1.重点:熟悉continue用法,因为将后面配对的字符串第一个字符标记为'B',所以遇到'B'则跳出循环
if(strand[i][0]=='B') continue;
//2.重点:通过将字符变为配对字符,从而为后面做遍历对比
for(int j=0;j<strand[i].length();j++){
if (strand[i][j]=='A')
strand[i][j]='T';
else if (strand[i][j]=='T')
strand[i][j]='A';
else if (strand[i][j]=='C')
strand[i][j]='G';
else if (strand[i][j]=='G')
strand[i][j]='C';
}
for(int k=i+1;k<n;k++){
if(strand[i]==strand[k]){
m=m+1;
strand[k][0]='B';
break;
}
}
}
cout << m <<endl;
}
//system("pause");
return 0;
}