알고리즘

C++ 알고리즘 - 백준 7785 회사에 있는 사람

마루설아 2025. 1. 11. 21:48

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

 

#include <bits/stdc++.h>
#include <unordered_map>
#define endl "\n"

using namespace std;

void CPP_INIT() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

bool compare(string a, string b) {
	return a > b;
}

int main(void) {
	CPP_INIT();

	int input;
	string str, str2;
	unordered_map<string, string> um;
	vector<string> v;

	cin >> input;
	for (int i = 0; i < input; i++) {
		cin >> str >> str2;
		um[str] = str2;
		v.push_back(str);
	}

	sort(v.begin(), v.end(), compare);
	v.erase(unique(v.begin(), v.end()), v.end());

	for (int i = 0; i < v.size(); i++) {
		if (um[v[i]] == "enter") cout << v[i] << endl;
	}
}