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之event
mysql之event http://blog.csdn.net/lxgwm2008/article/details/9088521 Mysql事件调度器(Event Scheduler)类似于定时器 ...
- 数据库——MySQL及安装
what's the MySQL MySQL是一个关系型数据库管理系统,MySQL 是目前最流行的关系型数据库管理系统之一,在 WEB 应用方面MySQL是最好的 RDBMS (Relational ...
- 下拉菜单被表单、图片、FLASH挡住的解决办法
设置Flash的参数: <param name="wmode" value="opaque"> <object classid="c ...
- python的join用法
1.使用方式: 字符串.join(序列) date = "".join(["2018-12-28", "00:00:00"])
- (转)Marathon健康检查
健康检查是需要每个应用运行监控检查任务的. 1.默认的健康检查是延迟才能让mesos知道任务的状态是否健康. 2.marathon提供一个任务资源的健康成员访问的REST API接口. 如果HTTP的 ...
- sync修饰符的简易说明
其实这个就说的很好了. sync会自动更新父组件的数据 原本valuechild 的值是222,父页面显示的222,把值传递给子组件 子组件也显示的222, 我点击子组件的按钮 把333传递给父组件, ...
- R语言的scale函数
1.数据的中心化 所谓数据的中心化是指数据集中的各项数据减去数据集的均值. 例如有数据集1, 2, 3, 6, 3,其均值为3 那么中心化之后的数据集为1-3,2-3,3-3,6-3,3-3,即:-2 ...
- 获取 Google USB 驱动程序
获取 Google USB 驱动程序 另请参阅 安装 USB 驱动程序 使用硬件设备 使用任何 Google Nexus 设备进行 ADB 调试时,只有 Windows 需要 Google ...
- C++ 退出双层for循环,解决 break、return、continue无法实现问题
遇到一个情景,采用双层for循环 遍历图像的像素,当找到某一个像素点满足条件时,退出双层for 循环 . 首先了解一下 continue.break.return 各自功能用法: 1.continue ...
- cocos2dx 3.x(游戏中的储存-UserDefault)
引擎提供的UserDefault可以简单地储存游戏中的信息,例如背景音乐音效的开关状态,用户名等等. UserDefault是一个单例对象,可以用getInstance方法来获得. 如果是第一次调 ...