70pts求条
查看原帖
70pts求条
823785
chen0717楼主2025/1/4 16:24
// Problem: P1786 帮贡排序
// Contest: Luogu
// URL: https://www.luogu.com.cn/problem/P1786
// Memory Limit: 125 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;

int n;

struct f{
    string mz;//名字 
    string ch;//称号 (职位) 
    int bg;//帮贡 
    int dj;//等级 
    int ch2;//称号2(比大小--排序用的) 
    int yuan;//原 
}k[60000];//结构体数组 ;

bool cmp1(f a,f b){
    return a.bg>b.bg; 
}//按帮贡排序 

bool cmp2(f a,f b){
    if(a.ch2!=b.ch2) return a.ch2>b.ch2;//先职位 
    else if(a.dj!=b.dj) return a.dj>b.dj;//后等级 
    else return a.yuan<b.yuan;
}//在调整过职位后,再次排序 

int main(){
    cin>>n;//输入n 
    
    for(int i=0;i<n;i++){
        cin>>k[i].mz>>k[i].ch>>k[i].bg>>k[i].dj;//输入名字、职位、帮贡、等级
		k[i].yuan=i; 
    }
    sort(k+3/*从除了帮主的开始排序*/,k+n,cmp1);//按帮贡排序 

    for(int i=3;i<n;i++){
        if(i-3<2){
            k[i].ch="HuFa";
            k[i].ch2=1919810;
        }
        else if(i-3-2<4){
            k[i].ch="ZhangLao";
            k[i].ch2=114514;
        }
        else if(i-3-2-4<7){
            k[i].ch="TangZhu";
            k[i].ch2=0;
        } 
        else if(i-3-2-4-7<25){
            k[i].ch="JingYing";
            k[i].ch2=-114514;
        }
        else{
            k[i].ch="BangZhong"; 
            k[i].ch2=-1919810;
        }
    }//帮贡排序后分发称号 

    sort(k+3/*从除了帮主的开始排序*/,k+n,cmp2);//在调整过职位后,再次排序
    for(int i=0;i<n;i++){
        cout<<k[i].mz<<' '<<k[i].ch<<' '<<k[i].dj<<endl;//输出 
    }
    return 0;
}
2025/1/4 16:24
加载中...