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.

Examples
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.

题解:模拟,枚举看是否有一个2*2矩形有3个字符相等

 #include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
ll gcd(ll a,ll b){
return b?gcd(b,a%b):a;
}
const int N=;
const int mod=1e9+;
char a[][];
bool flag=;
int main()
{
std::ios::sync_with_stdio(false);
for (int i=;i<=;i++) scanf("%s",a[i]+);
for (int i=;i<;i++){
for (int j=;j<;j++){
if(a[i][j]==a[i][j+]&&a[i][j]==a[i+][j]) flag=;
if(a[i][j]==a[i][j+]&&a[i][j]==a[i+][j+]) flag=;
if(a[i][j]==a[i+][j]&&a[i][j]==a[i+][j+]) flag=;
if(a[i+][j]==a[i][j+]&&a[i+][j]==a[i+][j+]) flag=;
}
}
if (flag) printf("YES\n");
else printf("NO\n");
return ;
}

Codeforce 287A - IQ Test (模拟)的更多相关文章

  1. Codeforce#354_B_Pyramid of Glasses(模拟)

    题目连接:http://codeforces.com/contest/676/problem/B 题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的 题解:由于数据不 ...

  2. 用 IQ分布模拟图来测试浏览器的性能

    今天天气太凉快,跟这个日历上属于夏天的那一页显得格格不入!就连我我床下那台废弃的ThinkPad,居然也十分透凉气,那外壳连我的体温高都没有,于是,我就开始想一个方法,让我那个废弃的电脑发热,顺便用它 ...

  3. Codeforce 25A - IQ test (唯一奇偶)

    Bob is preparing to pass IQ test. The most frequent task in this test is to find out which one of th ...

  4. Codeforces Round #176 (Div. 1 + Div. 2)

    A. IQ Test 模拟. B. Pipeline 贪心. C. Lucky Permutation 每4个数构成一个循环. 当n为偶数时,n=4k有解:当n为奇数时,n=4k+1有解. D. Sh ...

  5. Codeforce 294A - Shaass and Oskols (模拟)

    Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to ...

  6. CodeForce 7 B - Memory Manager(模拟)

    题目大意:给你一段内存,要你进行如下的三个操作. 1.分配内存  alloc   X ,分配连续一段长度为X的内存. 如果内存不够应该输出NULL,如果内存够就给这段内存标记一个编号. 2.擦除编号为 ...

  7. CodeForce 439C Devu and Partitioning of the Array(模拟)

     Devu and Partitioning of the Array time limit per test 1 second memory limit per test 256 megabytes ...

  8. Kilani and the Game-吉拉尼的游戏 CodeForce#1105d 模拟 搜索

    题目链接:Kilani and the Game 题目原文 Kilani is playing a game with his friends. This game can be represente ...

  9. 格子游戏Grid game CodeForce#1104C 模拟

    题目链接:Grid game 题目原文 You are given a 4x4 grid. You play a game — there is a sequence of tiles, each o ...

随机推荐

  1. 怎么修改TOMCAT的默认主页为你自己项目的主页

    如果webapp下有一个abc的文件来下有一个index.html,想设置为首页怎么操作 方法: 修改tomcat/conf/web.xml文件.在web.xml文件中,有一段如下:<welco ...

  2. 20165236 2017-2018-2《Java程序设计》课程总结

    20165236 2017-2018-2<Java程序设计>课程总结 一.每周作业链接汇总: 1.我期望的师生关系 2.学习基础和C语言基础调查 3.20165236郭金涛 预备作业3 L ...

  3. bootbox.js官方文档中文版

    bootbox.js官方文档中文版简介:Bootbox.js是一个小型的JavaScript库,基于Bootstrap模态框开发,用于创建可编程的对话框. 不像原生的alert等对话框,所有的Boot ...

  4. 阿里云RDS备份在本地mysql快速还原

    本地准备: ##安装和RDS相同的mysql版本,拿mysql5.6为例 http://www.cnblogs.com/37yan/p/7513605.html ##安装Xtrabackup 包 cd ...

  5. sendmail 发送邮件 zabbix 自定义报警

    配合zabbix 触发脚本 达到自定义报警目的 #!/bin/bash # Created : 2015.12.08 # Updated : 2015.12.08 # Author : sanmuya ...

  6. js动态规划---最少硬币找零问题

    给定钱币的面值 1.5.10.25 需要找给客户 36 最少找零数为: 1.10.25 function MinCoinChange(coins){ var coins = coins; var ca ...

  7. Eclipse配置Github -分享你的代码

    搭建了虚拟机供练手用,想要保存练习代码,于是想在VM Eclipse上配置Github,从此随练随保存. 步骤:1. eclipse ->help->install new softwar ...

  8. VS中去掉空格虚点

    Ctrl + R+W 可以在VS中添加或移除 空格虚点.

  9. 用python.twisted.logfile每天记录日志,并用不记录stdout中的内容

    #导入的头 from twisted.python import logfrom twisted.python.logfile import * #开始记录,输入日志名和存放的路径,setStdout ...

  10. Selenium基本使用(十一)异常捕获

    1. 抛出异常和自定义异常 Python用异常对象(exception object)表示异常情况,遇到错误后,会引发异常.如果异常对象并未被处理或捕捉,程序就会用所谓的回溯(Traceback,一种 ...