코테분석#5-2 걸그룹 마스터 준석이(백준 16165)

정은경·2020년 2월 25일
0

알고리즘

목록 보기
11/125

문제


나의 풀이

count, quiz = map(int,input().split())
girls = {}

for i in range(0,count):
    group_name = input()
    num = int(input())
    g_list = []
    for j in range(0,num):
        g_list.append(input())
    g_list.sort()
    girls[group_name] = g_list

q = []
for i in range(0,quiz):
    temp = input()
    temp += ":"
    temp += input()
    q.append(temp)

for i in q:
    qq = i.split(':')
    if qq[1]=='0':
        for i in girls.get(qq[0]):
            print(i)
    else:
        for j in girls:
            if qq[0] in girls[j]:
                print(j)

쌤's 풀이

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)
profile
#의식의흐름 #순간순간 #생각의스냅샷

0개의 댓글