3 条题解
-
-1
求点赞
#include using namespace std; struct Student{ int m,d; string name; }; vector<Student> stu; bool cmpName(string a,string b){ if(a.size()!=b.size()) return a.size() < b.size(); return a < b; } int main(){ int n; cin>>n; for(int i=0;i<n;i++){ string na; int m,d; cin>>na>>m>>d; stu.push_back({m,d,na}); } bool hasAns = false; for(int month=1;month<=12;month++){ for(int day=1;day<=31;day++){ vector<string> same; for(auto s:stu){ if(s.m==month && s.d==day){ same.push_back(s.name); } } if(same.size()>=2){ hasAns = true; sort(same.begin(),same.end(),cmpName); cout<<month<<" "<<day; for(auto nm:same){ cout<<" "<<nm; } cout<<endl; } } } if(!hasAns){ cout<<"None"<<endl; } return 0; }
信息
- ID
- 468
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 7
- 标签
- 递交数
- 71
- 已通过
- 19
- 上传者