#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <iostream>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
string str;
map<string, string> nickname;
// Change 확인
for(int i =0; i < record.size(); i++){
if(record[i][0] == 'L')
continue;
stringstream ss(record[i]);
ss >> str;
ss >> str;
string uid = str;
ss >> str;
string name = str;
if(nickname[uid] == ""){
nickname[uid] = name;
}
else if(nickname[uid] != name){
nickname[uid] = name;
}
}
// 정답 추출
for(int i = 0; i < record.size(); i++){
stringstream ss(record[i]);
ss >> str;
ss >> str;
if(record[i][0] == 'E'){
answer.push_back(nickname[str] + "님이 들어왔습니다.");
}
else if(record[i][0] == 'L'){
answer.push_back(nickname[str] + "님이 나갔습니다.");
}
}
return answer;
}
Algorithm/오픈채팅방.cpp at master · Heydosomething/Algorithm (github.com)
'알고리즘 > 알고리즘 문제' 카테고리의 다른 글
알고리즘 문제 예상 대진표 c++ (0) | 2021.07.07 |
---|---|
백준 2581번 C++ (0) | 2020.12.29 |