[백준] 7785번

Jeanine·2022년 3월 22일
0

baekjoon

목록 보기
28/120
post-thumbnail

💻 C++ 기반

https://www.acmicpc.net/problem/7785

#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <vector>

using namespace std;

unordered_set<string> s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;

    while (n--)
    {
        string name, 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 (vector<string>::iterator i = ans.begin(); i != ans.end(); i++)
    {
        cout << *i << '\n';
    }

    return 0;
}
profile
Grow up everyday

0개의 댓글