본문 바로가기
CS(Computer Science)지식/[C++][코딩 테스트] 자료구조 및 알고리즘

백준 7785번: 회사에 있는 사람 [C++]

by 엔지니어 청년 2024. 1. 31.

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';

}