https://www.acmicpc.net/problem/9375
import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
N = int(input())
dic = dict()
for _ in range(N):
a, b = map(str, input().split(" "))
# 종류별로 개수 저장 (안 입은 경우까지)
dic[b] = dic.get(b, 1) + 1
dap = 1
# 모든 경우의 수 저장
for i, j in dic.items():
dap *= dic[i]
# 모두 안입은 경우 -1
print(dap-1)'코딩테스트 > 코딩테스트 문제풀이' 카테고리의 다른 글
| [Python] 백준 <4889-안정적인 문자열> (0) | 2025.06.21 |
|---|---|
| [Python] 백준 <2792-보석 상자> (0) | 2025.06.21 |
| [Python] 백준 <1966-프린터 큐> (0) | 2025.06.11 |
| [Python] 백준 <1058-친구> (0) | 2025.06.09 |
| [Python] 백준 <4948-베르트랑 공준> (0) | 2025.06.09 |