本题关键就是贪心,对于1,n的情况
能到b以为着从1/n一定能到,到不了的情况也就是b - k <= 1 && b + k >= n
上述条件不满足,那么从1/n一定能到b,接下来就是保证a一定能到b,怎么实现?就是看a能不能到
1/n,也就是如果a - k <= 1 && a + k >= n 这样也是一定到不了
注意特判a = b的时候,这是一定能到的
// Problem: 奇怪的电梯
// Contest: NowCoder
// URL: https://ac.nowcoder.com/acm/contest/40229/C
// Memory Limit: 524288 MB
// Time Limit: 2000 ms
// Date: 2024-03-22 08:35:14
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
#define endl '\n'
#define int int64_t
#define ld long double
using namespace std;
void solve() {
int n, k, a, b; cin >> n >> k >> a >> b;
if (a != b && (b - k <= 1 && b + k >= n || a - k <= 1 && a + k >= n)) cout << "NO\n";
else cout << "YES\n";
}
signed main() {
ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}