9375번: 패션왕 신해빈
첫 번째 테스트 케이스는 headgear에 해당하는 의상이 hat, turban이며 eyewear에 해당하는 의상이 sunglasses이므로 (hat), (turban), (sunglasses), (hat,sunglasses), (turban,sunglasses)로 총 5가지 이다.
www.acmicpc.net
import sys
input = sys.stdin.readline
N = int(input())
for _ in range(N):
M = int(input())
clothe_dict={}
for i in range(M):
wear = list(input().split())
if wear[1] in clothe_dict:
clothe_dict[wear[1]].append(wear[0])
else:
clothe_dict[wear[1]] = [wear[0]]
print(clothe_dict)
cnt=1
for k in clothe_dict:
cnt *= (len(clothe_dict[k])+1)
print(cnt-1)
진짜 파이썬스러운 코드같다. 인터넷 참고해서 풀었다.
'취준 > 백준' 카테고리의 다른 글
2004 - 백준 (0) | 2022.05.11 |
---|---|
1676 - 백준 (0) | 2022.05.11 |
11051 - 파이썬 (0) | 2022.05.06 |
3036 - 파이썬 (0) | 2022.05.06 |
2981 - 파이썬 (0) | 2022.05.05 |