题目
题解
容易发现:除了四个角以外,每条边上的格子不会相互影响,所以关键是四个角的状态。穷举所有四个角的情况,然后逐一判断。
代码
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,u,r,d,l;
bool judge(int x,int y,int z,int w) //枚举四个角,0表示白色,1表示黑色
{
if(x+y+n-2<u||x+y>u) return 0;
if(y+z+n-2<r||y+z>r) return 0;
if(z+w+n-2<d||z+w>d) return 0;
if(x+w+n-2<l||x+w>l) return 0;
return 1;
}
bool solve()
{
for(int x=0;x<=1;x++)
for(int y=0;y<=1;y++)
for(int z=0;z<=1;z++)
for(int w=0;w<=1;w++)
if(judge(x,y,z,w)) return 1;
return 0;
}
int main()
{
int T; scanf("%d",&T);
while(T--)
{
scanf("%d%d%d%d%d",&n,&u,&r,&d,&l);
if(solve()) printf("YES\n");
else printf("NO\n");
}
return 0;
}