天天看点

Educational Codeforces Round 105 (Rated for Div. 2)B. Berland Crossword

思路:

#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
 
int check(int uu, int rr, int dd, int ll,int u, int r, int d, int l,int zs,int zx,int ys,int yx)
{
  if(uu >= u && rr >= r && dd >= d && ll >= l && ys+zs <= u && ys+yx <= r && yx+zx <= d && zs+zx <= l)
  return 1;
  else
  return 0;
}
int main()
{
  int t;
  scanf("%d",&t);
  while(t--)
  {
    int n,u,r,d,l;
    scanf("%d%d%d%d%d",&n,&u,&r,&d,&l);
    if(u > n|| r > n || d > n || l > n)
    {
      printf("no\n");
      continue;
    }
    else
    {
      int flag = 0;
      int maxx = n - 2;
      for(int ys = 0; ys < 2; ys++)
      {
        for(int yx = 0; yx < 2; yx++)
        {
          for(int zs = 0; zs < 2; zs++)
          {
            for(int zx = 0; zx < 2; zx++)
            {
              if(flag == 0)
              flag = check(maxx+ys+zs, maxx+ys+yx, maxx+yx+zx, maxx+zs+zx, u, r, d, l,zs,zx,ys,yx);
            }
          }
        }
      }
      if(flag)
      printf("yes\n");
      else
      printf("no\n");
    }
  }
}      

继续阅读