记录编号 570795 评测结果 AAAAAAAAAA
题目名称 [NOI Online 2020 3rd PJ]紧急救助(民间数据) 最终得分 100
用户昵称 Gravatardew52 是否通过 通过
代码语言 C++ 运行时间 0.000 s
提交时间 2022-04-18 21:56:26 内存使用 0.00 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100 + 5;
struct Node
{
    string name;
    string help;
    int score;
    int rnk;
}a[MAXN];
int n, maxn, maxn_num;
string ch;
bool cmp (Node a, Node b);
int search (int x, Node a[]);
int main()
{
    freopen("noi_online2020_save.in","r",stdin);
    freopen("noi_online2020_save.out","w",stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        cin >> ch;
        a[i].name = ch;
        string h; cin >> h;
        a[i].help = h;
        a[i].rnk = i;
    }
    for (int i = 1; i <= n; ++i)
    {
        a[i].score = search(i, a);
    }
    sort (a + 1, a + n + 1, cmp);
    for (int i = 1; i <= n; ++i)
    {
        maxn = max(maxn, a[i].score);
        //cout << a[i].score << " " << a[i].name << endl;
        if (a[i].score == maxn)
        {
            cout << a[i].name << " ";
        }
        else 
        {
            cout << endl;
            break;
        }
    }
    printf("%d\n", maxn);
    return 0;
}
int search (int x, Node a[])
{
    int sum = 0;
    for (int i = 0; i < a[x].help.size(); ++i)
    {
        //cout << a[x].help[i] << ' ' << a[x].help[i + 1] << " " << a[x].help[i + 2] << endl;
        if (a[x].help[i] == 's' && a[x].help[i + 1] == 'o' && a[x].help[i + 2] == 's')
        {
            sum++;
        }
    }
    return sum;
}
bool cmp (Node a, Node b)
{
    if (a.score != b.score)
    {
        return a.score > b.score;
    }
    else
    {
        return a.rnk < b.rnk;
    }
}