https://www.acmicpc.net/problem/16165
N, M = map(int, input().split())
group = {}
for i in range(N):
g_name = input()
member = int(input())
for j in range(member):
m_name = input()
group[g_name] = group.get(g_name, []) + [m_name]
for i in range(M):
name, num = input(), int(input())
if num == 0:
for n in sorted(group[name]):
print(n)
else:
for g in group:
if name in group[g]:
print(g)
N, M = map(int, input().split())
team_mem, mem_team = {}, {}
for i in range(N):
team_name, mem_num = input(), int(input())
team_mem[team_name] = []
for j in range(mem_num):
name = input()
team_mem[team_name].append(name)
mem_team[name] = team_name
for i in range(M):
name, q = input(), int(input())
if q:
print(mem_team[name])
else:
for mem in sorted(team_mem[name]):
print(mem)
팀명 - 멤버, 멤버 - 팀명 으로 구성된 딕셔너리를 두개 만드는 방법
'알고리즘 > 백준 (Pyhthon)' 카테고리의 다른 글
[알고리즘] 백준 1120 문자열 / python (0) | 2020.02.28 |
---|---|
[알고리즘] 백준 1012 유기농 배추 / python (0) | 2020.02.27 |
[알고리즘] 백준 17389 보너스점수 / python (0) | 2020.02.25 |
[알고리즘] 백준 17269 이름궁합 테스트 / python (0) | 2020.02.24 |
[알고리즘] 백준 9251 LCS / python (0) | 2020.02.12 |