Skip to content

Commit

Permalink
2024-05-23 23:25:15
Browse files Browse the repository at this point in the history
Affected files:
.obsidian/workspace.json
src/content/blog/boj-14425-문자열-집합.md
  • Loading branch information
gyunseo committed May 23, 2024
1 parent eaca6b7 commit a4e0a85
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 6 deletions.
30 changes: 24 additions & 6 deletions .obsidian/workspace.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@
}
}
]
},
{
"id": "f050f861ca13820a",
"type": "tabs",
"children": [
{
"id": "5aacb1a472f91ae8",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "src/content/blog/boj-14425-문자열-집합.md",
"mode": "source",
"source": false
}
}
}
]
}
],
"direction": "vertical"
Expand Down Expand Up @@ -86,7 +104,7 @@
"state": {
"type": "backlink",
"state": {
"file": "src/content/blog/boj-5014-스타트링크.md",
"file": "src/content/blog/boj-14425-문자열-집합.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
Expand All @@ -103,7 +121,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "src/content/blog/boj-5014-스타트링크.md",
"file": "src/content/blog/boj-14425-문자열-집합.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
Expand All @@ -126,7 +144,7 @@
"state": {
"type": "outline",
"state": {
"file": "src/content/blog/boj-5014-스타트링크.md"
"file": "src/content/blog/boj-14425-문자열-집합.md"
}
}
}
Expand All @@ -149,8 +167,10 @@
"table-editor-obsidian:Advanced Tables Toolbar": false
}
},
"active": "0f0fd716299d38e2",
"active": "5aacb1a472f91ae8",
"lastOpenFiles": [
"src/content/blog/boj-5014-스타트링크.md",
"src/content/blog/boj-14425-문자열-집합.md",
"dist/assets/[email protected]",
"dist/assets/forrest-gump-quote.webp.jpg",
"dist/_astro/[email protected]",
Expand All @@ -171,8 +191,6 @@
"dist/posts/우테코-2차-소감문.png",
"dist/posts/우테코-1차-소감문.png",
"dist/posts/virtual-lans.png",
"dist/posts/windows에서-wsl을-완전히-삭제하자.png",
"src/content/blog/boj-5014-스타트링크.md",
"src/content/blog/boj-11725-트리의-부모-찾기.md",
"src/content/blog/boj-1935-후위-표기식2.md",
"src/content/blog/boj-15666-N과-M-(12).md",
Expand Down
50 changes: 50 additions & 0 deletions src/content/blog/boj-14425-문자열-집합.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
author: Gyunseo Lee
title: "BOJ 백준 14425: 문자열 집합"
pubDatetime: 2024-05-23T22:42:00+09:00
modDatetime: 2024-05-23T22:42:00+09:00
featured: false
draft: false
tags:
- PS
- Algorithms
- BOJ
- 실랜디
- HashMap
description: HashMap 자료구조인 Set을 잘 활용하자!
ogImage: ""
---

## Table of contents

## 들어가며

이 문제는 파이썬의 HashMap 자료구조인 `set` 객체를 사용하여 풀면 됩니다.
`set` 객체를 쓰면 정말 쉽게 풀 수 있습니다.
그래도 이왕 문제 푸는 김에 뭔가를 얻어 가면 좋겠죠?
그래서 `set` 객체가 왜 HashMap 자료구조인지 GitHub CPython repo를 보면서 감을 잡았습니다.
[CPython에서 Set Object C언어 코드](https://github.com/python/cpython/blob/main/Objects/setobject.c)

## 풀이 과정

![](https://res.cloudinary.com/gyunseo-blog/image/upload/f_auto/v1716474146/image_zc53hm.png)

## AC 받은 Python 코드

```python
import sys

input = sys.stdin.readline

if __name__ == "__main__":
N, M = map(int, input().rstrip().split())
S = set()
ans = 0
for _ in range(N):
S.add(input().rstrip())
for _ in range(M):
if input().rstrip() in S:
ans += 1
print(ans)

```

0 comments on commit a4e0a85

Please sign in to comment.