You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
bool judge(const pair<int, int> a, const pair<int, int> b) {
if (a.second != b.second) return a.second > b.second;
else
return a.first < b.first;
}
int main() {
//输入+输出重定向
freopen("../1292.txt", "r", stdin);
int n;
cin >> n;
vector<vector<char>> a(n + 1, vector<char>(n + 1));
vector<pair<int, int>> p;
for (int i = 1; i <= n; i++) {
int sum = 0;
for (int j = 1; j <= n; j++) {
cin >> a[i][j];
if (a[i][j] == 'W')sum += 3;
if (a[i][j] == 'D') sum += 1;
}
p.push_back({i, sum});
}
//按value排序如果value一样按key排序
sort(p.begin(), p.end(), judge);
//输出得分最高
int maxN = p[0].second;
cout << p[0].first << " ";
for (int i = 1; i < n; i++) {
if (p[i].second == maxN) cout << p[i].first << " ";
}
//关闭文件
fclose(stdin);
return 0;
}