์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
- OS
- ์ฌ๊ท
- DP
- java
- Spring
- BFS
- CVE
- web
- Reversing
- ์คํ
- ๊ตฌํ
- ๋ฐฑํธ๋ํน
- ๋ฌธ์์ด
- c++
- dynamic debugging
- JPA
- dfs
- ๊ทธ๋ฆฌ๋
- ์๋ฎฌ๋ ์ด์
- ๋์ ํฉ
- GCP
- ๋ถํ ์ ๋ณต
- ์ฐ์ ์์ ํ
- error
- ์์ ์ ๋ ฌ
- ์ต๋จ ๊ฒฝ๋ก
- ๋งต
- thymeleaf
- ์ด๋ถ ํ์
- ๋ฐ์ดํฌ์คํธ๋ผ
- Today
- Total
hades
[Baekjoon] 1764๋ฒ: ๋ฃ๋ณด์ก ๋ณธ๋ฌธ
๐ฅ ๋ฌธ์
https://www.acmicpc.net/problem/1764
๐ ์ค๊ณ
๋ฃ์ง๋ ๋ชปํ๊ณ , ๋ณด์ง๋ ๋ชปํ ์ฌ๋์ ์ด๋ฆ์ ์ฐพ์์ผ ํ๋ค. ๋ฃ์ง๋ ๋ชปํ ์ฌ๋์ ์ฐ์ ์ ์ฅํ๊ณ , ๋ณด์ง๋ ๋ชปํ ์ฌ๋์ด ์ ์ฅํ ์ฌ๋ ์ค์ ์๋์ง ํ์ธํ๋ฉด ๋๋ค.
๋ฌธ์์ด์ ํค๋ก ์ ์ฅํ ์ ์๋ ๋งต์ ์ด์ฉํ์ฌ ๋ฃ์ง๋ ๋ชปํ ์ฌ๋์ ๋จผ์ ์ ์ฅํ๊ณ , ๋ณด์ง๋ ๋ชปํ ์ฌ๋์ ๋งต์์ findํ์ฌ ์๋ค๋ฉด ๊ฒฐ๊ณผ ๋ฒกํฐ์ ์ ์ฅํ๋ค. ์ ์ฅ๋ ์ฌ๋์ ์ค๋ฆ์ฐจ์์ผ๋ก ์ ๋ ฌ ํ ์ถ๋ ฅํ๋ค.
๐ ํ์ด
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
int n, m;
string name;
map<string, int> mm;
vector<string> result;
int main() {
cin.tie(NULL);
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i=0; i<n; i++){
cin >> name;
mm.insert({name, 1});
}
for (int i=0; i<m; i++){
cin >> name;
if (mm.find(name) != mm.end()){
result.push_back(name);
}
}
sort(result.begin(), result.end());
cout << result.size() << "\n";
for (int i=0; i<result.size(); i++){
cout << result[i] << "\n";
}
return 0;
}
๐ ๋ฉ๋ชจ
๋ฌธ์์ด์ ๊ฐ์ง๊ณ ์ ๊ทผํ๋ ค๊ณ ํ ๋, ๋งต์ด ์ ์ฉํ๊ฒ ์ฐ์ธ๋ค.
'๐ PS > Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Baekjoon] 2178๋ฒ: ๋ฏธ๋ก ํ์ (0) | 2024.07.10 |
---|---|
[Baekjoon] 1931๋ฒ: ํ์์ค ๋ฐฐ์ (0) | 2024.07.09 |
[Baekjoon] 1697๋ฒ: ์จ๋ฐ๊ผญ์ง (0) | 2024.07.08 |
[Baekjoon] 1620๋ฒ: ๋๋์ผ ํฌ์ผ๋ชฌ ๋ง์คํฐ ์ด๋ค์ (0) | 2024.07.07 |
[Baekjoon] 1541๋ฒ: ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2024.07.05 |