博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #176 (Div. 2) A. IQ Test(简单搜索)
阅读量:4647 次
发布时间:2019-06-09

本文共 2617 字,大约阅读时间需要 8 分钟。

A. IQ Test
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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

The test is as follows: the person gets a piece of squared paper with a 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 square, completely consisting of cells of the same color. If the initial picture already has such a square, the person should just say so and the test will be completed.

Your task is to write a program that determines whether it is possible to pass the test. You cannot pass the test if either repainting any cell or no action doesn't result in a 2 × 2 square, consisting of cells of the same color.

Input

Four lines contain four characters each: the 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

Print "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

In the first test sample it is enough to repaint the first cell in the second row. After such repainting the required 2 × 2 square is on the intersection of the 1-st and 2-nd row with the 1-st and 2-nd column.

 

1 #include 
2 #include
3 #include
4 #include
5 //#include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 #define ll long long16 #define cti const int17 #define ctll const long long18 #define dg(i) cout << '*' << i << endl;19 20 char map[5][5];21 const int move[4][2] = { { 0, 0}, { 0, 1}, { 1, 1}, { 1, 0}};22 23 bool Check(int i, int j)24 {25 int w = 0, b = 0;26 for(int k = 0; k < 4; k++)27 {28 if(map[i + move[k][0]][j + move[k][1]] == '#') b++;29 else w++;30 }31 if(w == 1 || b == 1 || w == 0 || b == 0) return true;32 return false;33 }34 35 int main()36 {37 while(scanf("%s", map[0]) != EOF)38 {39 int ok = false;40 for(int i = 1; i < 4; i++)41 scanf("%s", map[i]);42 for(int i = 0; i < 3 && !ok; i++)43 {44 for(int j = 0; j < 3 && !ok; j++)45 ok = Check(i, j);46 }47 if(ok) puts("YES");48 else puts("NO");49 }50 return 0;51 }

 

转载于:https://www.cnblogs.com/cszlg/archive/2013/03/30/2990643.html

你可能感兴趣的文章
SQL Server 数据库备份
查看>>
INNO SETUP 获得命令行参数
查看>>
Charles抓取https请求
查看>>
LAMP环境搭建
查看>>
C语言的变量的内存分配
查看>>
clientcontainerThrift Types
查看>>
链接全局变量再说BSS段的清理
查看>>
hdu 1728 逃离迷宫
查看>>
HTML5与CSS3权威指南之CSS3学习记录
查看>>
docker安装部署
查看>>
AVL树、splay树(伸展树)和红黑树比较
查看>>
多媒体音量条显示异常跳动
查看>>
运算符及题目(2017.1.8)
查看>>
React接入Sentry.js
查看>>
ssh自动分发密匙脚本样板
查看>>
转 小辉_Ray CORS(跨域资源共享)
查看>>
Linux安装postgresql
查看>>
MyBatis启动:MapperStatement创建
查看>>
【 全干货 】5 分钟带你看懂 Docker !
查看>>
[转]优化Flash性能
查看>>