import java.util.HashMap;
import java.util.Scanner;
// 패션왕 신해빈 - S3 - 조합문제
public class ex9375 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int n = sc.nextInt();
while(n-- >0){
HashMap<String,Integer> map = new HashMap<>();
int m = sc.nextInt();
while(m-- >0){
sc.next();
String kind = sc.next();
map.put(kind,map.getOrDefault(kind,0)+1);
}
int result=1;
for(String s : map.keySet()) result *= (map.get(s)+1);
System.out.println(result-1);
}
}
}
이 문제는 몇 가지의 옷 종류를 통한 옷입는 방법의 조합을 물어보는 문제이다.
조합을 이용해서 해결한다.
이렇게 구성된다. 옷을 안입는 경우도 경우이다. 이렇게 해서 모든 경우의 수는 3x2가 되는데 여기서 알몸은 안된다고 되어있기 때문에 둘다 NULL인 경우는 빼주면 된다.