#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