首页 > 其他分享 >CF 287A(IQ Test-枚举3个字符相等的矩阵)

CF 287A(IQ Test-枚举3个字符相等的矩阵)

时间:2022-10-25 10:01:22浏览次数:74  
标签:int square && IQ flag CF painted 287A th


A. IQ Test



time limit per test

memory limit per test



input



output



In the city of Ultima Thule job applicants are often offered an IQ test.

4 × 4 square painted on it. Some of the square's cells are painted black and others are painted white. Your task is to repaint at most one cell the other color so that the picture has a 2 × 2

2 × 2



Input



j-th character of the i-th line equals "." if the cell in the i-th row and the j-th column of the square is painted white, and "#", if the cell is black.



Output



YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise.



Sample test(s)



input



#### .#.. #### ....



output



YES



input



#### .... #### ....



output



NO



Note



2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column.







枚举看是否有一个矩形有3个字符相等



一开始居然把4个判断打错了?《上午也是……



#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>
using namespace std;
#define MAXLen (4+10)
char a[MAXLen][MAXLen];
bool flag=0;
int main()
{
for (int i=1;i<=4;i++) scanf("%s",a[i]+1);
for (int i=1;i<4;i++)
for (int j=1;j<4;j++)
{
if (a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]) flag=1;
if (a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]) flag=1;
if (a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]) flag=1;
if (a[i+1][j]==a[i][j+1]&&a[i+1][j]==a[i+1][j+1]) flag=1;

}
if (flag) printf("YES\n");
else printf("NO\n");
return 0;
}



标签:int,square,&&,IQ,flag,CF,painted,287A,th
From: https://blog.51cto.com/u_15724837/5794020

相关文章

  • CF 286A(Lucky Permutation-数列找规律)
    A.LuckyPermutationtimelimitpertestmemorylimitpertestinputoutputp......
  • 1.1 WCF SOA架构和webservice
    1.什么是SOA?SOA全称:面向服务架构(serviceOrientedArchitecture),它是一种组件架构模式。一、定义1.WebService:严格来说是行业标准,不是技术,使用XML扩展标记语言来表示数据......
  • CF1716F
    与CF932E,CF1278F其实差不多捏。首先\(m\)中奇数个数是\(\left\lceil\frac{m}{2}\right\rceil\),偶数个数是\(\left\lfloor\frac{m}{2}\right\rfloor\)。下文为了方便......
  • [CF1753C]Wish I Knew How to Sort
    做题时间:2022.10.25\(【题目描述】\)给定一个长度为\(n\)的01序列\(a\)和一种操作,你需要用这种操作将序列从小到大排序。操作为:等概率随机选择两个位置\(i,j(i<j)\)......
  • CF1278F
    与CF932E其实是差不多的捏设\(p=\dfrac{1}{m},q=1-p\),那么枚举第一张是王牌的次数,有如下式子:\[\sum_{i=1}^{n}\binom{n}{i}p^iq^{n-i}i^k\]后面那个\(i^k\)可以展......
  • .NET Core C#系列之XiaoFeng.Data.IQueryableX ORM框架
    ​         当前对象操作数据库写法和EFCore极度类似,因为现在大部分程序员都懒得去写SQL,再一个就是项目作大了或其它原因要改数据库,每次改数据库,那么写的SQL语......
  • CF1744B Even-Odd Increments
    简要题意\(T\)组数据,每组数据给定一个长度为\(n\)的数列,有\(q\)次操作,共有两种操作:\(\texttt{0x}\),给数列中所有偶数加上\(x\);\(\texttt{1x}\),给数列中所有奇......
  • CF932E
    先介绍这样一个等式:\[n^m=\sum_{i=1}^{m}\begin{Bmatrix}m\\i\end{Bmatrix}\timesi!\times\binom{n}{i}\]等式左边的组合意义是\(m\)个不同的球放入\(n\)个不同的......
  • CF1753A1
    前言题目传送门!更好的阅读体验?提供一种更加好理解的方法。思路关键点:只要凑够就行,不需要区间数量最小。首先,每个数是\(-1\)或\(1\),说明\(n\)为奇数时,必定无解。......
  • CF1753B 题解
    前言题目传送门!更好的阅读体验?其实挺简单的,赛时多打了个等号,被人叉了。思路关键是\(n!\times(n+1)=(n+1)!\)。原因很显然:\((1\times2\times\cdots\tim......