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 ...
随机推荐
- thinkphp无法安装提示修改mysql配置
在安装以thinkphp为框架的系统时数据库连接错误,提示修改sql-mode或sql_mode为NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION.那我们就顺着提示 ...
- [NOSQL] Redis介绍
Redis概述 Redis是Salvatore Sanfilippo在2009年为其初创公司LLOOGG开发的,眼下仍是独立项目.但VMWare赞劣了项目(作者是其雇员).它採用C语言实现.因此性能非 ...
- RN Animated透明度动画
主要代码解析: 如果我们希望吧Animated.Value从0变化到1,把组件位置从60px移动到0px,把不透明度从0编导1,就可以使用style的属性来实现 <Animated.Text s ...
- python类型错误:can only concatenate list (not "str") to list
TypeError:can only concatenate list (not "str") to list: 类型错误:只能将list类型和list类型联系起来,而不是str类 ...
- ansible进阶模板和角色使用
使用场景 Ansible 由于采用ssh远程连接登录管理,虽然不需要额外安装agent,但是速度慢效率低.不适合管理大规模的主机一般最大规模在200-300台,超大规模的主机管理适合使用puppet ...
- 前端框架之Vue(6)-列表渲染
用v-for把一个数组对应为一组元素 我们用 v-for 指令根据一组数组的选项列表进行渲染. v-for 指令需要使用 item in items 形式的特殊语法, items 是源数据数组并且 i ...
- 八种排序算法--java实现(转)
(转:http://blog.csdn.net/without0815/article/details/7697916) 8种排序之间的关系: 1, 直接插入排序 (1)基本思想:在要排序的一组数中, ...
- drf频率组件
1.简介 控制访问频率的组件 2.使用 手写一个自定义频率组件 import time #频率限制 #自定义频率组件,return True则可以访问,return False则不能访问 class ...
- 【Android】adb connect 手机的两种方式
adb支持两种连接Android系统的方式,USB方式及网络方式.一般android手机及android平板默认会设置为USB方式(直接插数据线的方式). 下边介绍两种方式的切换方式. 1. 背景知识 ...
- syslog-ng 学习
摘要:http://luyongxin88.blog.163.com/blog/static/925580720112275183903/ 因为工作的需要,涉及到了syslog-ng.现在看来,在外包 ...