考虑到问题其实最难处理的就是公共点的情况,所以想到最后我们可以二进制来枚举四个角,无非就是2的四次方。。。
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
using namespace std;
#define LL long long
typedef unsigned long long ull;
#define eps (1e-5)
const int maxn = 1e4 + 10;
const LL inf = 1e15;
const int bas = 131;
int n, U, R, D, L;
bool check(int a, int b)
{
if (a <= b && a + n - 2 >= b)return true;
else return false;
}
int main()
{
int t;
scanf("%d", &t);
while (t--)
{
cin >> n >> U >> R >> D >> L;
int flag = 0;
for (int i = 0; i < (1 << 4); i++)
{
int a1 = 0, a2 = 0, a3 = 0, a4 = 0;
if (i & (1 << 0))
{
a1++, a4++;
}
if (i & (1 << 1))
{
a1++, a2++;
}
if (i & (1 << 2))
{
a2++, a3++;
}
if (i & (1 << 3))
{
a3++, a4++;
}
if (check(a1, U) && check(a2, R) && check(a3, D) && check(a4, L))
{
flag = 1;
break;
}
}
if (flag)printf("YES\n");
else printf("NO\n");
}
return 0;
}