9375_패션왕 신해빈 (Python)
0. 출처
- 유형 : 해시 (silver 3)
- 링크 : 9375번: 패션왕 신해빈
1. 기록
- 22/06/30 (목)
2. 풀이
(1) 아이디어, 시간복잡도, 자료구조
1. 아이디어
{
'headgear':['hat','turban'],
'eyewear':['sungalsses']
}
2. 시간복잡도
>>
3. 자료구조
>> 해시
(2) 예제 입력, 예제 출력
- 예제 입력 1 -
테스트 케이스 / 해빈이가 가진 의상의 수
2
3
hat headgear
sunglasses eyewear
turban headgear
3
mask face
sunglasses face
makeup face
- 예제 출력 1 -
5
3
(3) 코드
import sys
def input():
return sys.stdin.readline().rstrip()
t = int(input())
def OOTD(n):
temp = {}
for _ in range(n):
wear, type = input().split()
if type in temp:
temp[type].append(wear)
elif type not in temp:
temp[type] = [wear]
answer = 1
for key in temp:
answer *= (len(temp[key])+1)
print(answer-1)
for _ in range(t):
n = int(input())
OOTD(n)
(4) 정리
(5) 참고
'코테기록 > 백준' 카테고리의 다른 글
[백준] 9461_파도반 수열 (Python) (0) | 2022.06.30 |
---|---|
[백준] 9095_1, 2, 3 더하기 (Python) (0) | 2022.06.30 |
[백준, 삼성 기출] 20056_마법사 상어와 파이어볼 (Python) (0) | 2022.04.24 |
[백준, 삼성 기출] 20057_마법사 상어와 토네이도 (Python) (0) | 2022.04.23 |
[백준, 삼성 기출] 19236_청소년 상어 (Python) (0) | 2022.04.23 |