不是哥们
2024-07-15 14:31:02
发布于:上海
26阅读
0回复
0点赞
#include <iostream>
#include <vector>
#include <climits>
#include <unordered_map>
#include <algorithm>
using namespace std;
int main() {
int a;
cin >> a;
vector<string> b(a);
for (int i = 0; i < a; ++i) {
cin >> b[i];
}
unordered_map<char, vector<vector<int>>> c;
for (int i = 0; i < 10; ++i) {
for (char ch = '0'; ch <= '9'; ++ch) {
c[ch].push_back(vector<int>());
}
}
for (int i = 0; i < a; ++i) {
for (int j = 0; j < 10; ++j) {
c[b[i][j]][j].push_back(i);
}
}
int sum = INT_MAX;
for (char ch = '0'; ch <= '9'; ++ch) {
vector<int> num;
for (int i = 0; i < 10; ++i) {
if (!c[ch][i].empty()) {
num.push_back((c[ch][i].size() - 1) * 10 + i);
}
}
if (!num.empty()) {
int temp = *max_element(num.begin(), num.end());
sum = min(sum, temp);
}
}
cout << sum << endl;
return 0;
}
这里空空如也
有帮助,赞一个