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 |
Tags
- 백트래킹
- 다이나믹 프로그래밍
- 스택
- c++
- 자료구조
- 수학
- 그리디 알고리즘
- 구현
- 알고리즘
- 누적 합
- 유니온 파인드
- 시뮬레이션
- XR Interaction Toolkit
- 그래프
- 문자열
- VR
- Unreal Engine 5
- 브루트포스
- 우선순위 큐
- DFS
- 재귀
- 트리
- ue5
- 유니티
- 투 포인터
- BFS
- Team Fortress 2
- 다익스트라
- 정렬
- 백준
Archives
- Today
- Total
1일1알
백준 22233번 가희와 키워드 C++ 본문
https://www.acmicpc.net/problem/22233
22233번: 가희와 키워드
1번째 글을 쓰고 난 후에, 메모장에 있는 키워드는 set, floyd, os가 됩니다. 2번째 글을 쓰고 난 후에, 메모장에 있는 키워드는 set, os가 됩니다. map은 1번째 글과 2번째 글에 중복으로 등장하였음을
www.acmicpc.net
set으로 하면 안되고 unordered_set으로 하면 통과된다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, m;
cin >> n >> m;
unordered_set<string> s;
for (int i = 0; i < n; i++) {
string str;
cin >> str;
s.insert(str);
}
for (int i = 0; i < m; i++) {
string str;
cin >> str;
string tmp = "";
int front = 0;
for (int j = 0; j <= str.length(); j++) {
if (j != str.length() && str[j] != ',') continue;
tmp = str.substr(front, j - front);
front = j + 1;
s.erase(tmp);
}
cout << s.size() << "\n";
}
}
'알고리즘' 카테고리의 다른 글
백준 1411번 비슷한 단어 C++ (0) | 2023.03.05 |
---|---|
백준 7795번 먹을 것인가 먹힐 것인가 C++ (0) | 2023.03.04 |
백준 2942번 퍼거슨과 사과 C++ (0) | 2023.03.02 |
백준 20208번 진우의 민트초코우유 C++ (0) | 2023.03.01 |
백준 11332번 시간초과 C++ (1) | 2023.02.28 |