Files
python/TangDou/XiTi/1292.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

39 lines
1.0 KiB
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}