Berland Crossword(枚举)

传送门

考虑到问题其实最难处理的就是公共点的情况,所以想到最后我们可以二进制来枚举四个角,无非就是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;
}
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值