【题解】CF1494B Berland Crossword

前往:我自己搭建的博客

题目

CF1494B Berland Crossword

题解

容易发现:除了四个角以外,每条边上的格子不会相互影响,所以关键是四个角的状态。穷举所有四个角的情况,然后逐一判断。

代码

#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;
}

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值