Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions mj010504/Programmers/μ˜€ν”ˆμ±„νŒ…λ°©.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include<bits/stdc++.h>

using namespace std;

struct chat {
char c;
string id, name;
};

map<string, string> mp; // id, name

chat toChat(string input) {
vector<string> sv; string temp;
stringstream ss(input);

while(getline(ss, temp, ' ')) {
sv.push_back(temp);
}

if(sv.size() == 2) {
return {'l', sv[1], mp[sv[1]]};
}

if(sv.size() == 3) {
mp[sv[1]] = sv[2];

if(sv[0] == "Enter") return {'e', sv[1], sv[2]};
else{ // change
return {'c', sv[1], sv[2]};
}
}
}

string toKoreanChat(chat ct) {
string temp = "";
string name = mp[ct.id];
if(ct.c == 'l') {
temp = name + "λ‹˜μ΄ λ‚˜κ°”μŠ΅λ‹ˆλ‹€.";
}

if(ct.c == 'e') {
temp = name + "λ‹˜μ΄ λ“€μ–΄μ™”μŠ΅λ‹ˆλ‹€.";
}

return temp;
}

vector<string> solution(vector<string> rv) {
vector<string> res;
vector<chat> chats;
for(int i = 0; i < rv.size(); i++) {
auto ct = toChat(rv[i]);
if(ct.c != 'c') chats.push_back(toChat(rv[i]));
}

for(auto ct : chats) {
res.push_back(toKoreanChat(ct));
}

return res;
}