import java.util.*;
import java.io.*;
class Solution {
public int solution(String[][] clothes) {
Map<String,String> cloth_category = new HashMap<>();
Map<String,Integer> category_cloth = new HashMap<>();
for(String[] cloth : clothes){
cloth_category.put(cloth[0],cloth[1]);
}
// 의상 종류별 옷의 개수
for(Map.Entry<String,String> entry : cloth_category.entrySet()){
String cloth = entry.getKey();
String category = entry.getValue();
category_cloth.put( category
, category_cloth.getOrDefault(category, 0) + 1 ); //실수 : put(category) 인데 cloth를 함.
}
//조합의 수 각각 구한 뒤 곱하기 (1이상 n이하)
int[] arr = new int[category_cloth.size()];
int idx = 0;
for(Map.Entry<String,Integer> entry : category_cloth.entrySet()){
int count = entry.getValue(); //n번째 카테고리의 옷 개수
arr[idx] += combi(count+1,1);
idx++;
}
//각 조합의 곱
int sum = 1;
for(int i = 0 ; i < category_cloth.size() ; i++){
sum *= arr[i];
}
return sum-1; // 아무것도 안입는경우 1개 빼기
}
static int combi(int m, int n){
if(n==0 || n==m) return 1;
return combi(m-1,n-1) + combi(m-1,n);
}
}