1 solutions
-
0
#include<bits/stdc++.h> using namespace std; const int N=180; struct Stu{ string s; int y,d; }stu[N]; bool cmp(Stu a,Stu b) { if(a.y<b.y) return 1; if(a.y==b.y&&a.d<b.d) return 1; if(a.y==b.y&&a.d==b.d&&a.s.size()<b.s.size()) return 1; if(a.y==b.y&&a.d==b.d&&a.s.size()==b.s.size()&&a.s<b.s) return 1; return 0; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>stu[i].s>>stu[i].y>>stu[i].d; } sort(stu+1,stu+1+n,cmp); int cnt=0; //表示有没有出现过生日相同的 for(int i=1;i<=n;i++) { int j=i; while(j<=n&&stu[i].y==stu[j].y&&stu[i].d==stu[j].d) j++; j--; int len=j-i+1; if(len>=2) { cout<<stu[i].y<<" "<<stu[j].d<<" "; for(int k=i;k<=j;k++) { cout<<stu[k].s<<" "; } cout<<endl; cnt++; } i=j; } if(cnt==0) { cout<<"None"; } return 0; }
Information
- ID
- 2875
- Time
- 1000ms
- Memory
- 64MiB
- Difficulty
- 9
- Tags
- # Submissions
- 13
- Accepted
- 2
- Uploaded By