[파이썬] 백준 - 14단계 집합과 맵
숫자카드 (10815)
N = int(input())
card = set(map(int,input().split()))
M = int(input())
compare = list(map(int,input().split()))
for i in compare:
if i in card:
print(1,end=' ')
else:
print(0,end=' ')
문자열 집합 (11425)
N,M = map(int,input().split())
count = 0
table = {}
for i in range(N):
S = input()
table[S] = 0
for i in range(M):
check = input()
if check in table :
table[check] += 1
temp = list(table.values())
print(sum(temp))
회사에 있는 사람 (7785)
N = int(input())
table = {}
for i in range(N):
name,now = map(str,input().split())
table[name] = now
result = [key for key, value in table.items() if value == 'enter']
result.sort(reverse=True)
for i in result:
print(i)
나는야 포켓몬 마스터 이다솜 (1620)
import sys
N,M = map(int,input().split())
num_name,name_num = {},{}
for i in range(N):
a = sys.stdin.readline().strip()
num_name[i+1] = a
name_num[a] = i+1
for i in range(M):
a = sys.stdin.readline().strip()
if 'A' <= a[0] <= 'z' :
print(name_num[a])
else :
print(num_name[int(a)])
sys 쓸줄 몰라서 5번은 틀렸다.. 코드는 잘 짰는데
숫자카드2 (10816)
N = int(input())
card_list = list(map(int,input().split()))
card_set = set(card_list)
M = int(input())
compare = list(map(int,input().split()))
table = dict(zip(card_set,[0 for i in range(len(card_set))]))
for i in card_list :
if i in table:
table[i] += 1
for j in compare :
if j in table:
print(table[j],end=' ')
else :
print(0,end=' ')
듣보잡 (1764)
N,M = map(int,input().split())
name,answer = {},[]
for i in range(N):
a = input()
name[a] = 0
for i in range(M):
b = input()
if b in name :
answer.append(b)
answer.sort()
print(len(answer))
for i in answer :
print(i)
대칭차집합 (1269)
A,B = map(int,input().split())
set_A = set(map(int,input().split()))
set_B = set(map(int,input().split()))
AB = list(set_A^set_B)
print(len(AB))
서로 다른 부분 문자열의 개수 (11478)
S = input()
word = set(S)
count = len(word)+1
for i in range(2,len(S)):
temp = {}
for j in range(len(S)-i+1):
if S[j:j+i] not in temp :
temp[S[j:j+i]] = 0
count += 1
print(count)
'Algorithm > etc' 카테고리의 다른 글
[파이썬] 백준 - 실랜디 (0) | 2023.04.20 |
---|---|
[파이썬] 백준 - 18단계 심화2 (0) | 2023.04.19 |
[파이썬] 백준 - 17단계 조합론 (0) | 2023.04.19 |
[파이썬] 백준 - 13단계 정렬 (0) | 2023.04.17 |
[파이썬] 백준 - 10단계 기하: 직사각형과 삼각형 (0) | 2023.04.08 |
[파이썬] 백준 - 9단계 약수, 배수와 소수 (0) | 2023.04.08 |
[파이썬] 백준 - 7단계 2차원 배열 (0) | 2023.04.06 |
댓글