RE 求救
查看原帖
RE 求救
1399098
JinHc1218楼主2024/8/7 15:47

它全部输出完后报了个 Received signal 6: Aborted / IOT trap.

代码:(全 RE)

#include<bits/stdc++.h>
using namespace std;
map<string, int> m = {
    {"Bangzhu", 0},
    {"FuBangZhu", 1},
    {"HuFa", 2},
    {"ZhangLao", 3},
    {"TangXhu", 4},
    {"JingYing", 5},
    {"BangZhong", 6}
};
int n;
struct player{
    string name;
    string work;
    int gong;
    int level;
}a[111], b[111];
int cmp1(const player &a, const player &b){
    if(a.work == "BangZhu") return 1;
    if(b.work == "BangZhu") return 0;
    if(a.work == "FuBangZhu") return 1;
    if(b.work == "FuBangZhu") return 0;
    if(b.gong != a.gong) return b.gong < a.gong;
    return b.level < a.level;
}
int index(const player &p){
    for(int i = 0; i < n; i++){
        if(p.name == a[i].name) return i;
    }
    return n;
}
int cmp2(const player &a, const player &b){
    if(a.work != b.work) return m[a.work] < m[b.work];
    if(a.level != b.level) return a.level > b.level;
    return index(a) < index(b);
}
void getp(player &p){
    cin >> p.name >> p.work >> p.gong >> p.level;
}
void putp(player p){
    cout << p.name <<' '<< p.work <<' '<< p.level <<endl;
}
int main(){
    cin >> n;
    for(int i = 0; i < n; i++) getp(a[i]);
    memcpy(b, a, sizeof(a));
    stable_sort(a, a + n, cmp1);
    for(int i = 0; i < min(1, n); i++) a[i].work = "BangZhu";
    for(int i = 1; i < min(3, n); i++) a[i].work = "FuBangZhu";
    for(int i = 3; i < min(5, n); i++) a[i].work = "HuFa";
    for(int i = 5; i < min(9, n); i++) a[i].work = "ZhangLao";
    for(int i = 9; i < min(16, n); i++) a[i].work = "TangZhu";
    for(int i = 16; i < min(41, n); i++) a[i].work = "JingYing";
    for(int i = 41; i < n; i++) a[i].work = "BangZhong";
    stable_sort(a, a + n, cmp2);
    for(int i = 0; i < n; i++) putp(a[i]);
    return 0;
}
2024/8/7 15:47
加载中...