#include <string>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
vector<string> msgs, uids;
map<string, string> m; // (uid, nickname)
int i, size = record.size();
for (i = 0; i < size; i++) {
istringstream ss(record[i]);
string type, uid, nick;
ss >> type >> uid >> nick; // type: 메시지 종류, uid: uid, nick: 닉네임
if (type == "Enter") msgs.push_back("님이 들어왔습니다.");
else if (type == "Leave") msgs.push_back("님이 나갔습니다.");
if (type != "Change") uids.push_back(uid); // enter | leave
if (type != "Leave") m[uid] = nick; // enter | change
}
for (i = 0; i < uids.size(); i++) answer.push_back(m[uids[i]] + msgs[i]);
return answer;
}