반응형
7785번: 회사에 있는 사람
첫째 줄에 로그에 기록된 출입 기록의 수 n이 주어진다. (2 ≤ n ≤ 106) 다음 n개의 줄에는 출입 기록이 순서대로 주어지며, 각 사람의 이름이 주어지고 "enter"나 "leave"가 주어진다. "enter"인 경우는
www.acmicpc.net
C++
#include <iostream>
#include <set>
#include <vector>
using namespace std;
int main()
{
cin.tie(0)->sync_with_stdio(0);
int N, idx;
string name, status;
set<string> S;
cin >> N;
while (N--)
{
cin >> name >> status;
if (status == "enter")
S.insert(name);
else
S.erase(name);
}
// set의 내용물을 거꾸로 vector에 복사
vector<string> V(S.rbegin(), S.rend());
for (auto c : V)
cout << c << "\\n";
}
반응형