0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-30 20:56:29 +00:00
OI-codes/Luogu/P6565/P6565.cpp

42 lines
877 B
C++

#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 105;
struct node {
std::string name, help;
int id, cnt;
node()
: id(0),
cnt(0) {}
} a[N];
int n;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i].name >> a[i].help;
a[i].id = i;
for (int j = 2; j < a[i].help.size(); j++) {
if (a[i].help[j - 2] == 's' && a[i].help[j - 1] == 'o' && a[i].help[j] == 's') a[i].cnt++;
}
}
std::sort(a + 1, a + 1 + n, [](node a, node b) -> bool {
return a.cnt == b.cnt ? a.id < b.id : a.cnt > b.cnt;
});
int ans = 0, last = a[1].cnt;
while (a[++ans].cnt == last) {
cout << a[ans].name << ' ';
}
cout << endl
<< last << endl;
return 0;
}