进食后人(如果你用map但TLE#125
  • 板块CF670C Cinema
  • 楼主lgzbgz
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/12/8 14:54
  • 上次更新2024/12/8 17:44:54
查看原帖
进食后人(如果你用map但TLE#125
1030286
lgzbgz楼主2024/12/8 14:54
struct merry {
    int b, c, cnt;
    inline bool operator<(const merry a)const {
        if(mp[a.b] == mp[b]) {
            return mp[c] > mp[a.c];
        }
        return mp[b] > mp[a.b];

    }
} umy[mxn];

不要在结构体的比较函数中一直读取map中的数

    for(int i = 1; i <= m; i++) {
        int x = read();
        umy[i].b = mp[x];
        umy[i].cnt= i;
    }
    for(int i = 1; i <= m; i++) {
        int x = read();
        umy[i].c = mp[x];
    }

在外面直接把map中的对应值赋值给结构体,然后在结构体中直接比

2024/12/8 14:54
加载中...