Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- BERT #구글BERT #BERT의정석
- 트랜스포머 #자연어처리 #딥러닝 #구글 #attention #self-attention #BERT #transformer #deeplearing
- 트랜스포머 #transformer #attention #self-attention #어텐션 #인공지능 #AI #딥러닝 #NLP #자연어처리
- docker #우분투 #ubuntu #도커 설치 #docker 설치 #docker installation #우분투 도커
- pandas #folium #groupby #네이버부스트코스 #코칭스터디
- pytorch #cuda #우분투 torch #ubuntu pytorch #cuda torch #cuda pytorch
- 알고리즘 #levenshtein distance #편집거리 #edit distance
- 구름자연어처리과정
- docker #cuda #docker container #도커 #도커 컨테이너 #쿠다 #cuda 11.3
- jupyter notebook #anaconda #vscode #pytorch #딥러닝 #deep learning #vscode server #서버 vscode #ssh vscode #vscode cuda
- docker #도커 #도커 컨테이너 #docker container #도커 우분투
- 머신러닝
- ssh #우분투 ssh #우분터 서버 #도커 #우분투 도커 #docker #cuda #우분투 개발환경 #딥러닝 #ubuntu docker #ubuntu cuda
- GPU #cuda out of memory #gpu 메모리 #pytorch
- logistic regression
- Machine Learning
- cuda #centos #cuda삭제 #리눅스 #cenos cuda삭제
- 백준
- 구름
- 백준 #알고리즘 #골드
- docker #아나콘다 #anaconda #ubuntu anaconda #docker anaconda
- 깃허브 #우분투 #ubuntu #Github #깃허브 우분투 #깃헙 우분투 #깃헙
- GPU #jtorch GPU #파이토치 병렬 #파이토치 GPU #pytorch gpu #multi process torch #horovod
- 파이썬 #Python
Archives
- Today
- Total
바닥부터 시작하는 개발 공부
[알고리즘]백준 1764번: 듣보잡 본문
728x90
알고리즘 유형: 자료구조(해쉬)
문제
김진영이 듣도 못한 사람의 명단과, 보도 못한 사람의 명단이 주어질 때, 듣도 보도 못한 사람의 명단을 구하는 프로그램을 작성하시오.
입력
첫째 줄에 듣도 못한 사람의 수 N, 보도 못한 사람의 수 M이 주어진다. 이어서 둘째 줄부터 N개의 줄에 걸쳐 듣도 못한 사람의 이름과, N+2째 줄부터 보도 못한 사람의 이름이 순서대로 주어진다. 이름은 띄어쓰기 없이 알파벳 소문자로만 이루어지며, 그 길이는 20 이하이다. N, M은 500,000 이하의 자연수이다.
듣도 못한 사람의 명단에는 중복되는 이름이 없으며, 보도 못한 사람의 명단도 마찬가지이다.
출력
듣보잡의 수와 그 명단을 사전순으로 출력한다.

풀이
두 유형의 집단에서 중복되어있는 사람을 출력하는 문제이다(듣보잡)
중복의 경우 딕셔너리를 활용하는것이 제일 간편하다
defaultdict의 경우 key 값이 없어도 지정한 값 혹은 default값으로 키에 밸류를 할당해준다
import sys
from collections import defaultdict
N, M =map(int, sys.stdin.readline().strip().split(" "))
blinder =defaultdict(int)
result =[]
for i in range(N):
man = sys.stdin.readline().strip()
blinder[man]+=1
for i in range(M):
man = sys.stdin.readline().strip()
blinder[man]+=1
if blinder[man]==2:
result.append(man)
result= sorted(result)
print(len(result))
for i in result:
print(i)
728x90
'Algorithm > 백준' 카테고리의 다른 글
[알고리즘]백준 1927번: 좌표 압축 (0) | 2023.02.07 |
---|---|
[알고리즘]백준 1427번: 소트인사이드 (0) | 2023.02.06 |
[알고리즘]백준 10610번: 30 (0) | 2023.02.06 |
[알고리즘]1541번: 잃어버린 괄호 (0) | 2023.02.06 |
[알고리즘]백준 4948번: 베르트랑 공준 (0) | 2023.02.06 |
Comments