[백준] 9375 패션왕 신해빈
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
if (n == 0) {
cout << "0\n";
continue;
}
map<string, int> types;
for (int i = 0; i < n; ++i) {
string name, type;
cin >> name >> type;
if (types.find(type) == types.end()) {
types[type] = 1;
}
else {
types[type] += 1;
}
}
int answer = 1;
for (auto i = types.begin(); i != types.end(); ++i) {
answer *= (i->second + 1);
}
answer--;
cout << answer << "\n";
}
return 0;
}