ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Educational Codeforces Round 105 B.Berland Crossword

2021-03-04 19:01:53  阅读:204  来源: 互联网

标签:Educational return Berland int Codeforces cin flag bool const


题目链接

思路

根据题目对U,R,D,L的定义,可知关键为四个边角的状态,于是考虑遍历四个边角的状态,0为白色,1为黑色并进行判断即可获得结果。

代码

#include<bits/stdc++.h>
using namespace std;
const int mod=3;
const int inf=0x3f3f3f3f;
string s;
stack<char>st;
int 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+w+n-2<r||y+w>r)
        return 0;//同上
    if(z+w+n-2<d||z+w>d)
        return 0;//同上
    if(x+z+n-2<l||x+z>l)
        return 0;//同上
    return 1;
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int t;
    cin>>t;
    while(t--)
    {
        bool flag=0;
        cin>>n>>u>>r>>d>>l;
        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))
                            flag=1;
                    }
                }
            }
        }
        if(flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

标签:Educational,return,Berland,int,Codeforces,cin,flag,bool,const
来源: https://blog.csdn.net/WTMDNM_/article/details/114375143

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有