피너클의 it공부방
백준 7785 회사에 있는 사람 (c++) : 피너클 본문
728x90
반응형
https://www.acmicpc.net/problem/7785
그냥 set을 이용해 구현하는 문제다.
#include <iostream>
#include <set>
#include <string>
using namespace std;
int n;
set<string> s;
string a, b;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a >> b;
if (b == "enter") {
s.insert(a);
}
else {
s.erase(a);
}
}
set<string>::reverse_iterator iter;
for (iter = s.rbegin(); iter != s.rend(); iter++) {
cout << *iter << "\n";
}
}
전체코드다.
들어와야 나갈수 있으니 erase전에 find를 하거나 하지는 않았다.
728x90
반응형
'백준' 카테고리의 다른 글
백준 2295 세 수의 합 (c++) : 피너클 (0) | 2024.11.28 |
---|---|
백준 9506 약수들의 합 (c+++) : 피너클 (0) | 2024.11.24 |
백준 32684 장기 (c++) : 피너클 (0) | 2024.11.23 |
백준 11005 진법 변환 2 (c++) : 피너클 (0) | 2024.11.22 |
백준 2745 진법 변환 (c++) : 피너 (0) | 2024.11.20 |