unordered_map<string,set<string>> id_map;
unordered_map<string,set<string>> mails;
for(int i=0; i<id_list.size(); i++){
id_map[id_list[i]] = {};
}
for(int j=0; j<report.size(); j++){
auto it = report[j].find(" ");
string id = report[j].substr(0,it);
string reporter = report[j].substr(it+1);
id_map[reporter].insert(id);
}
for(int j=0; j<report.size(); j++){
auto it = report[j].find(" ");
string id = report[j].substr(0,it);
string reporter = report[j].substr(it+1);
int report_num = id_map[reporter].size();
if(report_num >= k){
mails[id].insert(reporter);
}
}
❌ 1. 기준이 잘못 잡힘 (관점 오류)
int report_num = id_map[reporter].size();❌ 2. 자료구조의 키가 문제 조건과 안 맞음
id_map[reporter].insert(id);❌ 3. k 판단과 메일 분배가 동시에 섞여 있음
“모든 판단의 기준은 신고당한 사람(target) 이다”
unordered_set<string> uniq;
for (const string& r : report) {
int sp = r.find(' ');
string reporter = r.substr(0, sp);
string target = r.substr(sp + 1);
uniq.insert(reporter + " " + target);
}
vector<int> reportedCount(n, 0);
for (const string& key : uniq) {
int sp = key.find(' ');
string target = key.substr(sp + 1);
reportedCount[idx[target]]++;
}
vector<bool> banned(n, false);
for (int i = 0; i < n; i++) {
if (reportedCount[i] >= k)
banned[i] = true;
}
vector<int> answer(n, 0);
for (const string& key : uniq) {
int sp = key.find(' ');
string reporter = key.substr(0, sp);
string target = key.substr(sp + 1);
if (banned[idx[target]]) {
answer[idx[reporter]]++;
}
}