Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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
- 자료구조
- 논문리뷰
- 대수경
- 실버 4
- lqr
- mathematics for computer science
- 다리로봇
- mit
- 텔레스코픽로봇
- 전국 대학생 수학 경시대회
- 로보틱스
- std::sort
- 구현
- baekjoon problem solving
- MIT opencourse
- 수학
- LeggedRobot
- 백준
- 정렬
- 큐
- 최적제어
- BOJ
- C++
- 집합과 맵
- 실버 5
- baekjoon
- 6.042j
- 문자열
- HJB방정식
- 로봇공학
Archives
- Today
- Total
서두르지 말고 쉬지 말자
백준 1764 듣보잡 (C++) 본문
solved.ac 티어 : 실버4
문제 유형 : 자료구조, 문자열, 해시를 사용한 집합과 맵, 집합과 맵, 정렬
문제 해결 전략 : <set> 라이브러리 사용해서 해결했다. <set>은 요소 집어넣으면 알아서 정렬해줘서 정렬도 따로 해줄필요가 없다.
문제 해결 소감: STL로 푸니까 쉬움, 근데 일일히 구현해야 된다고 생각하면 아득해진다.
#include <iostream>
#include <set>
#include <string>
int n, m;
int cnt = 0;
std::string s;
std::set<std::string> s1;
std::set<std::string> s2;
std::set<std::string> ans;
int main(void) {
std::cin >> n >> m;
for (int i = 0; i < n; i++) {
std::cin >> s;
s1.insert(s);
}
for (int i = 0; i < m; i++) {
std::cin >> s;
s2.insert(s);
}
for (const std::string& x : s1) {
if (s2.find(x) != s2.end()) {
cnt++;
ans.insert(x);
}
}
std::cout << cnt << '\n';
for (const std::string& x : ans) {
std::cout << x << '\n';
}
return 0;
}반응형
'코딩 공부 > Baekjoon Problem Solving' 카테고리의 다른 글
| 백준 10814번 나이순 정렬 (C++) (0) | 2025.08.11 |
|---|---|
| 백준 7568번 덩치 (C++) (2) | 2025.08.04 |
| 백준 14626번 ISBN (C++) (3) | 2025.07.24 |
| 백준 2164번 카드 2(C++) (0) | 2025.07.16 |
| 백준 11650번 좌표 정렬하기 (C++) (2) | 2025.07.14 |
