题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
#include<bits/stdc++.h> using namespace std; int main() { string s; map<string, int>m; deque<string>d; while (getline(cin, s)) { s = s.substr(s.find_last_of('\\') + 1); int pos = s.find_last_of(' '); if (pos > 16) s = s.substr(pos - 16); if (m.find(s) == m.end()) d.push_back(s); ++m[s]; if (d.size() > 8) d.pop_front(); } for (auto i : d) cout << i << " " << m[i] << endl; }