https://www.acmicpc.net/problem/7785
// 회사에 있는 사람
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
unordered_set<string> set;
string name, status;
int n;
cin >> n;
while (n--)
{
cin >> name >> status;
if (status == "enter")
set.insert(name);
else
set.erase(name);
}
vector<string> v(set.begin(), set.end()); // 이렇게 벡터에 전부 넣어줄 수 있다
sort(v.begin(), v.end(), greater<string>()); // 역순 정렬
for (int i = 0; i < v.size(); i++)
cout << v[i] << '\n';
}
엄청 편리하다 해시 최고!
'<algorithm> > 백준' 카테고리의 다른 글
백준 1920 수 찾기 c++ (0) | 2023.09.11 |
---|---|
백준 10816 숫자 카드 2 c++ (0) | 2023.09.11 |
백준 1620 (c++) 나는야 포켓몬 마스터 이다솜 (0) | 2023.04.06 |
백준 1744 (c++) 수 묶기 (0) | 2023.03.23 |
백준 1700 (c++) 멀티탭 스케줄링 (0) | 2023.03.22 |