真求救:为何屡次RE
查看原帖
真求救:为何屡次RE
892579
L_Y_X楼主2024/1/20 20:53
#include <iostream>
#include <cstring>

using namespace std;

int n;
string name[110], s[110];
int count[110];

int main() {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> name[i] >> s[i];
    }

    int max = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < s[i].length() - 2; ++j) {
            if (s[i][j] == 's' && s[i][j + 1] == 'o' && s[i][j + 2] == 's') {
                count[i]++;
            }
        }
        if (count[i] > max) {
            max = count[i];
        }
    }

    for (int i = 1; i <= n; ++i) {
        if (count[i] == max) {
            cout << name[i] << " ";
        }
    }
    cout << endl;
    cout << max;
    return 0;
}

https://www.luogu.com.cn/record/143578410

2024/1/20 20:53
加载中...