家族迁徙5分!

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

int n;

struct node
{
string name;
int  year, xb, nl, age, w;
}a[1005];

bool cmp(node x, node y)
{
  if(x.w != y.w) return x.w < y.w;
  if(y.w == 1)
  {
    return x.year > y.year;
  }
  if(y.w == 2)
  {
    return x.year < y.year;
  }
  if(y.w == 3)
  {
    if(x.xb != y.xb) return x.xb > y.xb;
    else if(x.xb == 0) return x.year > y.year;
    else return x.nl < y.nl;
  }
}

int main()
{
  cin >> n;
  for(int i = 1; i <= n; i++)
    {
      cin >> a[i].name;
      string x, w;
      cin >> x;
      a[i].year = stoi(x.substr(6, 4));
        a[i].xb = (x[16] - '0') % 2;
        a[i].nl = stoi(x.substr(18));
        a[i].age = 2000 - a[i].year;
        if(a[i].age < 100) a[i].w = 1;
        else if(a[i].age > 1000) a[i].w = 2;
        else a[i].w = 3;
   }
  sort(a + 1, a + n + 1, cmp);
  for(int i = 1; i <= n; i++)
    {
      cout << a[i].name << "\n";
    }
}
1.打字习惯很不好
2.cmp函数太短了
3.题目是什么?

用stable_sort,保证排序的稳定性