1 条题解

  • 3
    @ 2023-11-25 18:26:24
    #include<bits/stdc++.h>
    using namespace std;
    struct sp{
    	char name[21];
    	int name1;
    	int m,d;
    } a[200];
    bool MY_sort(sp x,sp y)
    {
    	if(x.m!=y.m) return x.m<y.m;
    	else if(x.d!=y.d) return x.d<y.d;
    	else if(x.name1 !=y.name1) return x.name1<y.name1;
    	else{
    		int i=0;
    		while(x.name[i]==y.name[i]) i++;
    		return x.name[i]<y.name[i];
    	}
    }
    int main()
    {
    	//freopen("birthday.in","r",stdin); 
    	//freopen("birthday.out","w",stdout);
    	int n;cin>>n;
    	for(int i=1;i<=n;i++)
    	{
    		cin>>a[i].name>>a[i].m>>a[i].d;
    		a[i].name1=strlen(a[i].name);
    	}
    	sort(a+1,a+n+1,MY_sort);
    	int num=0;bool pan=0;
    	for(int i=1;i<=n;i++)
    	{
    		if(((a[i].m==a[i+1].m)&&(a[i].d==a[i+1].d))||((a[i].m==a[i-1].m)&&(a[i].d==a[i-1].d)))
    		{
    			pan=1;
    			if(num==0) cout<<a[i].m<<' '<<a[i].d<<' ';
    			num++;
    			cout<<a[i].name<<' ';
    			if((a[i].m!=a[i+1].m)||(a[i].d!=a[i+1].d))
    			{
    				cout<<endl;num=0;
    			}
    		}
    	}
    	if(pan==0) cout<<"None";
    	return 0;
    }
    
    • 1

    信息

    ID
    388
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    递交数
    148
    已通过
    34
    上传者