
경우의 수를 구하는 간단한 문제입니다.
백준에 있는 예시처럼 heargear 2종류, eyewear 1종류가 있을 때 각 가능한 경우의 수를 아래처럼 나열할 수 있습니다.

가능한 모든 조합은 3 x 2로 6가지입니다. 하지만 입고 있는 것이 하나도 없는 경우를 제외해야 하므로 1을 뺍니다.
#include <iostream>
#include <map>
int main()
{
int test;
std::cin >> test;
for (int t = 0; t < test; t++)
{
int cnt;
std::cin >> cnt;
std::map<std::string, int> wears;
for (int i = 0; i < cnt; i++)
{
std::string name, type;
std::cin >> name >> type;
if (wears.find(type) == wears.end()) wears.insert({ type, 2 });
else wears[type]++;
}
int result = 1;
for (const auto it : wears)
result *= it.second;
result--;
std::cout << result << "\n";
}
return 0;
}