1 条题解

  • 0
    @ 2024-4-23 17:38:55
    #include<bits/stdc++.h>
    #define ll long long
    using namespace std;
    struct node{
    	string x;
    	string y;
    	ll z;
    }c[100005];
    bool cmp1(node x1,node y1){
    	return x1.x<y1.x;
    }
    bool cmp2(node x2,node y2){
    	if(x2.y!=y2.y)return x2.y<y2.y;
    	else return x2.x<y2.x;
    }
    bool cmp3(node x3,node y3){
    	if(x3.z!=y3.z)return x3.z<y3.z;
    	else return x3.x<y3.x;
    }
    int main(){
    	ll a,b,f=0;
    	while(true){
    		cin>>a>>b;
    		if(a==0)return 0;
    		else{
    			for(ll i=1;i<=a;i++)cin>>c[i].x>>c[i].y>>c[i].z;
    			f++;
    			cout<<"Case "<<f<<":"<<endl;
    			if(b==1)sort(c+1,c+a+1,cmp1);
    			else if(b==2)sort(c+1,c+a+1,cmp2);
    			else if(b==3)sort(c+1,c+a+1,cmp3);
    			for(ll i=1;i<=a;i++){
    				cout<<c[i].x<<" "<<c[i].y<<" "<<c[i].z<<endl;
    			}
    		}
    	}
    }
    
    • 1

    信息

    ID
    771
    时间
    1000ms
    内存
    32MiB
    难度
    10
    标签
    递交数
    5
    已通过
    3
    上传者