https://www.acmicpc.net/problem/7785
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
unordered_set<string> s;
int n;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n;
while (n--)
{
string name;
string log;
cin >> name >> log;
if (log == "enter") s.insert(name);
else s.erase(name);
}
vector<string> ans(s.begin(), s.end());
sort(ans.begin(), ans.end(), greater<string>()); // 역순으로 정렬
for (auto x : ans) cout << x << '\n';
}
'CS(Computer Science)지식 > [C++][코딩 테스트] 자료구조 및 알고리즘' 카테고리의 다른 글
백준 9375번: 패션왕 신해빈 [C++] (0) | 2024.01.31 |
---|---|
백준 17219번: 비밀번호 찾기 [C++] (0) | 2024.01.31 |
백준 13414번: 수강신청 [C++] (0) | 2024.01.31 |
백준 1620번: 나는야 포켓몬 마스터 이다솜 [C++] (0) | 2024.01.31 |
바킹독의 실전 알고리즘 강의 총정리(C++, 코딩 테스트, 알고리즘) (1) | 2024.01.29 |