求助 map里装node 该怎么写node的排序简洁点
  • 板块学术版
  • 楼主ruye
  • 当前回复8
  • 已保存回复8
  • 发布时间2024/5/14 21:06
  • 上次更新2024/5/15 08:34:39
查看原帖
求助 map里装node 该怎么写node的排序简洁点
757864
ruye楼主2024/5/14 21:06
struct node{
    int a1, a2, a3, a4, a5;
    bool operator < (const node &that) const {
        if(a1 == that.a1 && a2 == that.a2 && a3 == that.a3 && a4 == that.a4) return a5 < that.a5;
        if(a1 == that.a1 && a2 == that.a2 && a3 == that.a3) return a4 < that.a4;
        if(a1 == that.a1 && a2 == that.a2) return a3 < that.a3;
        if(a1 == that.a1) return a2 < that.a2;
        return a1 < that.a1;
    }
};
map<node, int> mp;

如上面代码

2024/5/14 21:06
加载中...