-
Notifications
You must be signed in to change notification settings - Fork 22
/
0019.cpp
48 lines (44 loc) · 982 Bytes
/
0019.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 0019.简单错误记录
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
struct node
{
int cnt;
int num;
};
bool cmp(pair<string, node> p1, pair<string, node> p2){
return p1.second.num > p2.second.num;
}
int main()
{
string s;
map<string, node> mp;
int n = 0, num = 0;
node no;
//freopen("in.txt", "r", stdin);
while (getline(cin, s))
{
s = s.substr(s.rfind('\\')+1);
if(mp.find(s) == mp.end()) {
no.cnt = 1;
no.num = num;
mp[s] = no;
} else {
mp[s].cnt ++;
}
num ++;
}
vector<pair<string, node> > v(mp.begin(), mp.end());
sort(v.begin(), v.end(), cmp);
for(int i = v.size()>8?7:(v.size()-1); i >= 0; i--)
{
s = v[i].first;
int idx = s.find(' ');
if(idx > 16) s = s.substr(idx-16);
cout << s << ' ' << v[i].second.cnt << endl;
}
return 0;
}