• Codeforce 287A


    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个字符相等

     1 #include <iostream>
     2 #include <algorithm>
     3 #include <cstring>
     4 #include <cstdio>
     5 #include <vector>
     6 #include <cstdlib>
     7 #include <iomanip>
     8 #include <cmath>
     9 #include <ctime>
    10 #include <map>
    11 #include <set>
    12 using namespace std;
    13 #define lowbit(x) (x&(-x))
    14 #define max(x,y) (x>y?x:y)
    15 #define min(x,y) (x<y?x:y)
    16 #define MAX 100000000000000000
    17 #define MOD 1000000007
    18 #define pi acos(-1.0)
    19 #define ei exp(1)
    20 #define PI 3.141592653589793238462
    21 #define INF 0x3f3f3f3f3f
    22 #define mem(a) (memset(a,0,sizeof(a)))
    23 typedef long long ll;
    24 ll gcd(ll a,ll b){
    25     return b?gcd(b,a%b):a;
    26 }
    27 const int N=205;
    28 const int mod=1e9+7;
    29 char a[5][5];
    30 bool flag=0;
    31 int main()
    32 {
    33     std::ios::sync_with_stdio(false);
    34     for (int i=1;i<=4;i++) scanf("%s",a[i]+1);
    35     for (int i=1;i<4;i++){
    36         for (int j=1;j<4;j++){
    37             if(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j]) flag=1;
    38             if(a[i][j]==a[i][j+1]&&a[i][j]==a[i+1][j+1]) flag=1;
    39             if(a[i][j]==a[i+1][j]&&a[i][j]==a[i+1][j+1]) flag=1;
    40             if(a[i+1][j]==a[i][j+1]&&a[i+1][j]==a[i+1][j+1]) flag=1;
    41         }
    42     }
    43     if (flag) printf("YES
    ");
    44     else printf("NO
    ");
    45     return 0;
    46 }
  • 相关阅读:
    Flex 布局教程:语法篇
    ajax总结
    响应式技能储备
    响应式选项卡
    搜索框代码
    如何区分内存类型及查看内存的兼容性
    动手动脑4(03继承与多态)
    Log Explorer恢复sql误删数据
    判断YYYYMMDD这种格式的AJAX,基本上把闰年和2月等的情况都考虑进去了
    关于(object sender, System.EventArgs e)中参数sender和e的问题。
  • 原文地址:https://www.cnblogs.com/wydxry/p/7263777.html
Copyright © 2020-2023  润新知