qwq问一下为啥能通过编译啊
  • 板块灌水区
  • 楼主aldol_reaction
  • 当前回复4
  • 已保存回复4
  • 发布时间2021/7/18 10:00
  • 上次更新2023/11/4 14:19:56
查看原帖
qwq问一下为啥能通过编译啊
393190
aldol_reaction楼主2021/7/18 10:00
#include <stdio.h>
#include <algorithm>
#include <queue>
#include <unordered_map>
#define MN 1005

int n, m, a[MN + 5][MN + 5];

struct state {
    int x, y, d;
    operator int() {
        return id();
    }
    int id() {
        return (x * m + y) * 4 + d;
    }
    bool operator < (const state &that)const {
        if(this->x != that.x)
            return this->x < that.x;
        if(this->y != that.y)
            return this->y < that.y;
        return this->d < that.d;
    }
    bool operator != (const state &that)const {
        return (this->x != that.x) || (this->y != that.y) || (this->d != that.d);
    }
};

std::unordered_map<int, state> frm;

int main() {
    state S = {1, 1, 1};
    frm[S] = {0, 0, 0};
    frm['a'] = {2, 2, 2};
}

定义的map是int到state的映射,现在发现map的key也可以是char,甚至可以是state...看了cppreference没懂为什么可以QAQ

请大佬来给蒟蒻解惑qwq

2021/7/18 10:00
加载中...