#38325: cpp 紀錄


BensonDC2 (Cpp 戰士)

學校 : 不指定學校
編號 : 255493
來源 : [1.175.211.7]
最後登入時間 :
2023-11-16 21:02:06
e788. b3.畢業典禮(Ceremony) -- 2019年12月TOI練習賽 | From: [1.175.211.7] | 發表日期 : 2023-11-12 15:26

#include <bits/stdc++.h>
using namespace std;

struct student{
    int order;
    string id;
    string name;
};

bool cmp(student a,student b){
    if (a.id[8]!=b.id[8])
        return a.id[8]<b.id[8];
    else if (a.id[0]!=b.id[0])
        return a.id[0]<b.id[0];
    else return a.order<b.order;
}

 

int main(){
    int N;
    string a,b;
    scanf("%d", &N);
    student L[N];
    for (int i=0;i<N;++i){
        cin>>L[i].id>>L[i].name;
        L[i].order=i;
    }

    sort(L,L+N,cmp);
    for (int i=0;i<N;++i){
        cout<<L[i].id[8]<<": "<<L[i].name<<'\n';
    }
    return 0;
}

 
ZeroJudge Forum