Codeforces-287a C IQ Test
来源:互联网 发布:乐高 机器人 编程 编辑:程序博客网 时间:2024/05/16 06:41
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 repaintat most one cell the other color so that the picture has a2 × 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 a2 × 2 square, consisting of cells of the same color.
Four lines contain four characters each: the j-th character of thei-th line equals "." if the cell in thei-th row and the j-th column of the square is painted white, and "#", if the cell is black.
Print "YES" (without the quotes), if the test can be passed and "NO" (without the quotes) otherwise.
####.#..####....
YES
####....####....
NO
In the first test sample it is enough to repaint the first cell in the second row. After such repainting the required2 × 2 square is on the intersection of the1-st and 2-nd row with the1-st and 2-nd column.
————————————————————扎实的分割线————————————————————
思路:水题,纯模拟。枚举2×2的矩形。一旦一个小矩形内出现3个或3个以上# or . 称为有解。
代码如下:
#include <stdio.h>#include <string.h>int main(){char a[5][5];int i, j, flag = 0;for(i = 0; i < 4; i++) scanf("%s", a[i]);for(i = 0; i < 3; i++){//仅需要三次,想一想为什么 for(j = 0; j < 3; j++){ int x = 0, y = 0; if(a[i][j] == '#') x++; else y++; if(a[i][j+1] == '#') x++; else y++; if(a[i+1][j] == '#') x++; else y++; if(a[i+1][j+1] == '#') x++; else y++; if(x >= 3||y >= 3){ flag = 1; break; } } if(flag) break;}printf("%s\n", flag ? "YES" : "NO");return 0;}
- Codeforces-287a C IQ Test
- codeforces-25A-A. IQ test( C && 怡宝 )
- codeforces 328A. IQ Test
- codeforces A. IQ test 题解
- Codeforces 25A IQ test
- 【CodeForces】[25A]IQ test
- CodeForces Testing Round #8 A.IQ Test
- Codeforces 328A-IQ Test(数列)
- CodeForces 25A IQ test 唯一奇偶
- Codeforces Testing Round #8 / 328A IQ Test(模拟)
- Codeforces Beta Round #25 (Div. 2)--A. IQ test
- CodeForces 25A IQ test 唯一奇偶(简单的题目)
- codeforces——25A——IQ test
- A. IQ test
- A. IQ Test
- A. IQ test
- 【水模拟】#25 A. IQ test
- IQ Test
- 关于一个编辑器插入数据库需要转义的问题
- 使用golang学习算法(1)-排序
- C#之委托和事件
- (转)asp.net中的报销多级审批工作流
- 新学了一个数据结构bitset();bnu 4141
- Codeforces-287a C IQ Test
- 简单又好看的按钮,扁平化按钮.
- php.ini中的request_order设置
- JAVA_交通灯管理系统
- gif格式图片在安卓中的显示(自定义GifView)
- java 静态方法不能被override
- adb install无法安装apk
- Java进阶篇——容器(三)
- Cygwin 无法使用163源解决方法(不指向cygwin目录)