[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค-Lv2] ์œ„์žฅ / Python

๐Ÿ“š Problem Solving/Programmers

 

์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์œ„์žฅ

 

programmers.co.kr

import sys

input = sys.stdin.readline

clothes = [list((map(str, input().split()))) for _ in range(int(input()))]


def solution(clothes):
    temp = {}
    for i in clothes:
        if i[1] in temp:
            temp[i[1]] += 1
        else:
            temp[i[1]] = 1
    answer = 1
    for i in temp.values():
        answer *= i + 1
    return answer - 1


print(solution(clothes))

 

ํ•ด์„ค

๋”•์…”๋„ˆ๋ฆฌ๋ฅผ ์ด์šฉํ•ด ์˜ท ์ข…๋ฅ˜์˜ ๊ฐœ์ˆ˜๋ฅผ ์ €์žฅํ–ˆ๋‹ค. ๊ตฌํ•œ ๊ฐ’์œผ๋กœ ์ž…์„ ์ˆ˜ ์žˆ๋Š” ์˜ท์˜ ์กฐํ•ฉ ์ˆ˜๋ฅผ ๊ตฌํ•˜๋Š” ๊ณต์‹์€ (๊ฐ ์ข…๋ฅ˜ +1)์„ ์„œ๋กœ ๊ณฑํ•ด์ฃผ๊ณ  ๊ฒฐ๊ณผ์— ํ•˜๋‚˜๋ฅผ ๋นผ์ค€ ๊ฐ’์ด๋‹ค.