题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
#include <iostream> #include <string> #include<unordered_map> #include<queue> using namespace std; int main() { string str; string b; queue<string> que; unordered_map<string, int> unordered_map; while (cin >> str >> b) { // 注意 while 处理多个 case string name = {}; int size = str.size(); for (int i = 0; i < 16; i++){ if (str[size - i - 1] == '\\') break; name = str[size - i - 1] + name; } name = name + ' ' + b; if (unordered_map.find(name) == unordered_map.end()) que.push(name); unordered_map[name]++; if(que.size()>8) que.pop(); } while(que.size()){ string a = que.front(); que.pop(); cout << a << ' ' << unordered_map[a] << endl; } return 0; } // 64 位输出请用 printf("%lld")