3 条题解
-
3
#include<bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; if (!(cin >> n)) return 0; map<pair<int, int>, vector<string>> birthdayMap; for (int i = 0; i < n; ++i) { string name; int month, day; cin >> name >> month >> day; birthdayMap[{month, day}].push_back(name); } bool hasDuplicate = false; for (auto& entry : birthdayMap) { auto& names = entry.second; if (names.size() > 1) { hasDuplicate = true; sort(names.begin(), names.end(), [](const string& a, const string& b) { if (a.length() != b.length()) { return a.length() < b.length(); } return a < b; }); cout << entry.first.first << " " << entry.first.second; for (const auto& name : names) { cout << " " << name; } cout << "\n"; } } if (!hasDuplicate) { cout << "None\n"; } return 0; }
信息
- ID
- 468
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 7
- 标签
- 递交数
- 71
- 已通过
- 19
- 上传者