rt, 这份代码一直连样例点都过不去,因此本蒟蒻前来求助各位dalao
代码如下
/* La Vaguelette */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
const string OCC[] = {"NULL", "BangZhu", "FuBangZhu", "HuFa", "ZhangLao", "TangZhu", "JingYing", "BangZhong"}; // 所有职位
struct Person // 代表帮友的结构体
{
string name = "";
int occupation = 0;
int level = 0, contribution = 0, order = 0;
Person(string name, string occupation, int contribution, int level, int order)
{
this->name = name;
this->contribution = contribution;
this->level = level;
this->order = order;
for (int i = 1; i <= 7; ++i) // 将职位转化为数字,方便比较
{
if (OCC[i] == occupation)
{
this->occupation = i;
break;
}
}
}
};
bool cmp1(Person p1, Person p2) // 第一次排序所用函数
{
if (p1.contribution > p2.contribution)
return true;
if (p1.order < p2.order)
return true;
return false;
}
bool cmp2(Person p1, Person p2) // 第二次排序所用函数
{
if (p1.occupation < p2.occupation)
return true;
if (p1.level > p2.level)
return true;
if (p1.order < p2.order)
return true;
return false;
}
int main()
{
#ifdef LOCAL
freopen("./in.txt", "rb", stdin);
freopen("./out.txt", "wb", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int n;
cin >> n;
vector<Person> temp, arr; // temp用于暂时存储帮主和副帮主
for (int i = 0; i < n; ++i)
{
string name, occupation;
int contribution, level;
cin >> name >> occupation >> contribution >> level;
Person x = Person(name, occupation, contribution, level, i);
if (x.occupation != 1 && x.occupation != 2)
arr.push_back(x);
else
temp.push_back(x);
}
sort(arr.begin(), arr.end(), cmp1);
for (int i = 0; i < n - 3; ++i)
{
if (i < 2)
arr[i].occupation = 3;
else if (i < 6)
arr[i].occupation = 4;
else if (i < 13)
arr[i].occupation = 5;
else if (i < 38)
arr[i].occupation = 6;
else
arr[i].occupation = 7;
}
for (int i = 0; i < 3; ++i) // 将帮主和副帮主加入排序之中
arr.push_back(temp[i]);
sort(arr.begin(), arr.end(), cmp2);
for (int i = 0; i < n; ++i)
cout << arr[i].name << ' '
<< OCC[arr[i].occupation] << ' '
<< arr[i].level << endl;
return 0;
}