백준 풀이 C++

백준 7785 c++ set 역순 출력

ag2개발자 2022. 9. 23. 12:03
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss stable_sort
#define ll long long

struct cmp {
    bool operator()(const string& a, const string& b) const {
        return a > b;
    }
};

int main() {
    cin.tie(0)->sync_with_stdio(0);
    // for(int i=0; i< n;i++)

    int n;
    cin >> n;
    vector<string> v;
    set<string> se;
    while (n--) {
        string s, s2;
        cin >> s >> s2;
        if (s2 == "enter") {
            se.emplace(s);
        }
        else {
            se.erase(s);
        }
    }
    /*for (auto i : se) {
        cout << i << "\n";
    }*/
    for (auto it = se.rbegin(); it != se.rend(); it++) {
        cout << *it<<"\n";
    }


    return 0;
}