백준 알고리즘 7785번 : 회사에 있는 사람

Zoo Da·2021년 8월 15일
0

백준 알고리즘

목록 보기
164/337
post-thumbnail

링크

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

Sol) Set

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define MAX 1005
#define INF 1e9+7
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using dbl = double;
using ldb = long double; 
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pdbl = pair<double, double>;
using vi = vector<int>;
using tiii = tuple<int,int,int>;
#define sz(a) int((a).size())

int32_t main(){
  fastio;
  int n; cin >> n;
  set<string> s;
  while(n--){
    string a,b; cin >> a >> b;
    if(b == "enter") s.insert(a);
    else if(b == "leave" && a == *(s.find(a))) s.erase(a);
  }
  vector<string> names;
  for(auto &p : s) names.pb(p);
  sort(names.begin(), names.end());
  reverse(names.begin(), names.end());
  for(auto &p : names) cout << p << "\n";
  return 0;
}

profile
메모장 겸 블로그

0개의 댓글