CF1494B Berland Crossword

题目传送门


思路:

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

代码如下:

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+10;
const int INF=0x3f3f3f3f;
int T,n,u,r,d,l; 
bool judge(int x,int y,int z,int w){
	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;
}
signed main(){
	cin>>T;
	while(T--){
		cin>>n>>u>>r>>d>>l;
		if(solve()){
			cout<<"YES"<<endl;
		}else{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}

完结撒花~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值