Codefroces Educational Round 26 837 B. Flag of Berland
1 second
256 megabytes
standard input
standard output
The flag of Berland is such rectangular field n × m that satisfies following conditions:
- Flag consists of three colors which correspond to letters 'R', 'G' and 'B'.
- Flag consists of three equal in width and height stripes, parralel to each other and to sides of the flag. Each stripe has exactly one color.
- Each color should be used in exactly one stripe.
You are given a field n × m, consisting of characters 'R', 'G' and 'B'. Output "YES" (without quotes) if this field corresponds to correct flag of Berland. Otherwise, print "NO" (without quotes).
The first line contains two integer numbers n and m (1 ≤ n, m ≤ 100) — the sizes of the field.
Each of the following n lines consisting of m characters 'R', 'G' and 'B' — the description of the field.
Print "YES" (without quotes) if the given field corresponds to correct flag of Berland . Otherwise, print "NO" (without quotes).
6 5
RRRRR
RRRRR
BBBBB
BBBBB
GGGGG
GGGGG
YES
4 3
BRG
BRG
BRG
BRG
YES
6 7
RRRGGGG
RRRGGGG
RRRGGGG
RRRBBBB
RRRBBBB
RRRBBBB
NO
4 4
RRRR
RRRR
BBBB
GGGG
NO
The field in the third example doesn't have three parralel stripes.
Rows of the field in the fourth example are parralel to each other and to borders. But they have different heights — 2, 1 and 1.
大模拟,n m被三整除
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#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 ios() ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int n,m;
char s[][];
char name[]={'B','G','R'};
bool check(int x,int n,int y,int m,char c)
{
for(int i=x;i<=n;i++)
{
for(int j=y;j<=m;j++)
{
if(s[i][j]!=c) return false;
}
}
return true;
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
scanf("%s",s[i]+);
bool flag=false;
do
{
if(n%==)
{
bool falg=true;
for(int i=;i<;i++)
{
if(!check(i*n/+,(i+)*n/,,m,name[i])) falg=false;
}
if(falg)flag=true;
}
if(m%==)
{
bool falg=true;
for(int i=;i<;i++)
{
if(!check(,n,i*m/+,(+i)*m/,name[i])) falg=false;
}
if(falg)flag=true;
}
}while(next_permutation(name,name+));
puts(flag?"YES":"NO");
return ;
}
Codefroces Educational Round 26 837 B. Flag of Berland的更多相关文章
- Codefroces Educational Round 26 837 D. Round Subset
D. Round Subset time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...
- Codefroces Educational Round 26 837 C. Two Seals
C. Two Seals time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
- Codefroces Educational Round 27 845G Shortest Path Problem?
Shortest Path Problem? You are given an undirected graph with weighted edges. The length of some pat ...
- Codefroces Educational Round 27 (A,B,C,D)
A. Chess Tourney time limit per test 1 second memory limit per test 256 megabytes input standard inp ...
- Educational Codeforces Round 26
Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...
- CodeForces 837F - Prefix Sums | Educational Codeforces Round 26
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...
- CodeForces - 837E - Vasya's Function | Educational Codeforces Round 26
/* CodeForces - 837E - Vasya's Function [ 数论 ] | Educational Codeforces Round 26 题意: f(a, 0) = 0; f( ...
- CodeForces 837D - Round Subset | Educational Codeforces Round 26
/* CodeForces 837D - Round Subset [ DP ] | Educational Codeforces Round 26 题意: 选k个数相乘让末尾0最多 分析: 第i个数 ...
- Educational Codeforces Round 26 B,C
B. Flag of Berland 链接:http://codeforces.com/contest/837/problem/B 思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出 ...
随机推荐
- PostgreSQL Replication之第六章 监控您的设置(1)
在本书的前几章,您已经学习了各种复制以及如何配额制各种类型的场景.现在是时候通过增加监控来让您的设置更加可靠了. 在本章中,您将学习监控什么以及如恶化实施合理的监控车辆.您将学习: • 检查您的 XL ...
- codeforces 527 C Glass Carving
Glass Carving time limit per test 2 seconds Leonid wants to become a glass carver (the person who cr ...
- Linux 下易用的光盘镜像管理工具(虚拟光驱软件)转载
作者: Frazer Kline | 2014-11-23 11:07 评论: 4 收藏: 4 分享: 10 磁盘镜像包括了整个磁盘卷的文件或者是全部的存储设备的数据,比如说硬盘,光盘(DVD,C ...
- Linux 中挂载 ISO 文件
在 Linux 中挂载 ISO 文件 用 mount 命令,在终端中输入如下命令即可: sudo mount -o loop filename.iso /cdrom 其中 filename.iso 是 ...
- windows上 python有多版本,如何管理,如何区别?
win10环境下: 1. where python 查看安装了哪些版本. 2.更改对应python.exe 文件的名称就能更改调用python的名称了. 3.不同python是两个完全独立的软件(独立 ...
- 快速创建WCF服务和svcutil.exe工具使用
先简单的创建WCF服务: 系统会自动加上IService1接口 和 Service1 实现类 分别在IService1 和Service1 加上2段代码. [ServiceContract] publ ...
- ArcGIS api for javascript——加入动态地图
描述 这个示例展示了增加一个按用户缩放或平移服务器每次绘制的地图.这样的地图没有切片的cache并被调用一个动态地图服务图层.ArcGISDynamicMapServiceLayer表示ArcGIS ...
- cocos2dx 3.0 windows8下开发环境搭建搭建 不须要cygwin
已经接触cocos2dx有一段时间,但一直也仅仅是看看Demo,没有真正的去写代码.由于本人仅仅是java的coder.还是半路出家的coder,编程基础太浅. 对于c++.lua也不懂.近期coco ...
- Android 五大存储方式具体解释
SharedPreferences与Editor SharedPreferences保存的数据仅仅要是类似于配置信息格式的数据.因此它保存的数据主要是简单的key-value对形式.以下关系图 上图全 ...
- poj3169 差分约束系统
题意: 从1到n,n个数,从左向右依次排列. 给定两种形式的约束条件: 1.xi与yi的最大距离为dk 2.xi与yi的最小距离为dk 问满足这些限定条件的情况下,数1和n的最大距离是多少?(若约束条 ...