很喜欢力扣用户的一句话:
鉴定为躺床题,只要牢象不演,牢车不可能两步逮捕不了牢后,看能不能第一步直接吃到,能就1不能就2
——1ov313773r
class Solution {
public:
bool in_between(int l, int m, int r) {
return min(l, r) < m && m < max(l, r);
}
int minMovesToCaptureTheQueen(int a, int b, int c, int d, int e, int f) {
return (a==e&&(c != e || !in_between(b, d, f))|| b == f && (d != f || !in_between(a, c, e))||c + d == e + f && (a + b != e + f || !in_between(c, a, e))|| c - d == e - f && (a - b != e - f || !in_between(c, a, e)))?1:2;
}
};