题解 | #简单错误记录#
简单错误记录
https://www.nowcoder.com/practice/2baa6aba39214d6ea91a2e03dff3fbeb
#include <iostream> #include <utility> #include <vector> #include <string> #include <queue> #include <map> using namespace std; int main() { string c; int line; map<pair<string,int>,int> ans; queue<pair<string,int>> deq; while(cin>>c>>line) { int pos=0,last=0; while((pos=c.find('\\',last))!=-1) last=pos+1; string name=c.substr(last,c.size()); if(name.length()>16) name=name.substr(name.size()-16,name.size()); pair p=make_pair(name,line); if(ans.find(p)==ans.end()) deq.push(p); ans[p]++; if(deq.size()>8) deq.pop(); } while(!deq.empty()) { cout<<deq.front().first<<" "<<deq.front().second<<" "<<ans[deq.front()]<<endl; deq.pop(); } } // 64 位输出请用 printf("%lld")