반응형

 

📖 문제

 

📋 코드

import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int T = sc.nextInt();

		for (int i = 0; i < T; i++) {
			int N = sc.nextInt();
			int ans = 1;
			HashMap<String, Integer> map = new HashMap<>();
			for (int j = 0; j < N; j++) {
				String name = sc.next();
				String type = sc.next();
				if (map.get(type) == null) {
					map.put(type, 1);
				} else {
					map.put(type, map.get(type) + 1);
				}

			}
			for (int val : map.values()) {
				ans *= (val + 1);
			}
			System.out.println(ans - 1);
		}
	}
}

👨🏻‍💻 결과

 

 

🔗 링크

https://www.acmicpc.net/problem/9375

 

9375번: 패션왕 신해빈

첫 번째 테스트 케이스는 headgear에 해당하는 의상이 hat, turban이며 eyewear에 해당하는 의상이 sunglasses이므로   (hat), (turban), (sunglasses), (hat,sunglasses), (turban,sunglasses)로 총 5가지 이다.

www.acmicpc.net

 

반응형

+ Recent posts