0
点赞
收藏
分享

微信扫一扫

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

西风白羽 2022-10-25 阅读 149


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



举报

相关推荐

0 条评论