Codeforce 287A - IQ Test (模拟)
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.
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.
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 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 (模拟)的更多相关文章
- Codeforce#354_B_Pyramid of Glasses(模拟)
题目连接:http://codeforces.com/contest/676/problem/B 题意:给你一个N层的杯子堆成的金字塔,倒k个杯子的酒,问倒完后有多少个杯子的酒是满的 题解:由于数据不 ...
- 用 IQ分布模拟图来测试浏览器的性能
今天天气太凉快,跟这个日历上属于夏天的那一页显得格格不入!就连我我床下那台废弃的ThinkPad,居然也十分透凉气,那外壳连我的体温高都没有,于是,我就开始想一个方法,让我那个废弃的电脑发热,顺便用它 ...
- 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 ...
- 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 ...
- Codeforce 294A - Shaass and Oskols (模拟)
Shaass has decided to hunt some birds. There are n horizontal electricity wires aligned parallel to ...
- CodeForce 7 B - Memory Manager(模拟)
题目大意:给你一段内存,要你进行如下的三个操作. 1.分配内存 alloc X ,分配连续一段长度为X的内存. 如果内存不够应该输出NULL,如果内存够就给这段内存标记一个编号. 2.擦除编号为 ...
- 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 ...
- Kilani and the Game-吉拉尼的游戏 CodeForce#1105d 模拟 搜索
题目链接:Kilani and the Game 题目原文 Kilani is playing a game with his friends. This game can be represente ...
- 格子游戏Grid game CodeForce#1104C 模拟
题目链接:Grid game 题目原文 You are given a 4x4 grid. You play a game — there is a sequence of tiles, each o ...
随机推荐
- mysql show prifile基本详解
show profile默认情况下,参数处于关闭状态,并保存最近15次的运行结果查看profile是否开启 show variables like '%profi%';开启profile记录功能 se ...
- 微星笔记本每次都进bios
解决方法 bios中更改启动模式,要更改为LEGACY
- Python3学习之路~4.3 装饰器
定义:本质是函数,装饰其他函数就是为其他函数添加附加功能. 原则: 不能修改被装饰函数的源代码 不能修改被装饰函数的调用方式 实现装饰器知识储备: 函数即“变量” 高阶函数 把一个函数名当做实参传递给 ...
- 如何在ASP.NET 网站项目中使用C# 6?
作者:Generic链接:https://www.zhihu.com/question/48864375/answer/113316462来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业 ...
- abap对象的创建和调用。方法调用
1: abap中创建类和创建对象,调用方法. *&---------------------------------------------------------------------* ...
- syslog-ng应用详解
syslog-ng应用详解 科技小能手 2017-11-07 02:43:00 浏览136 评论0 日志 LOG 配置 主机 syslog source file varchar 摘要: 最近做一 ...
- 【Java】-NO.13.Algorithm.1.Java Algorithm.1.001-【Java 常用算法手册 】-
1.0.0 Summary Tittle:[Java]-NO.13.Algorithm.1.Java Algorithm.1.001-[Java 常用算法手册 ]- Style:Java Series ...
- 详解Laravel的目录结构
Models 目录在哪里? 许多初学者可能都会困惑 Laravel 为什么没有提供 models 目录,官方解释说是因为不同人对 models 这个词的含义看法不同,容易造成歧义,有些开发者认为应用的 ...
- mac xcode 常见配置
1.报错:There are no schemes in workspace "..." 设置scheme共享,方法: 2.Build 文件夹是中间文件的保存地方,如何设置在工程目 ...
- [LeetCode] 566. Reshape the Matrix_Easy
In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...