题意翻译

题目描述

根据一项新的ISO标准,每一个国家的国旗应该是一个n×m的格子场,其中每个格子最多有10种不同的颜色。并且国旗应该有条纹:旗帜的每一行应包含相同颜色的方块,相邻的行的颜色应该是不同的。Berland政府要求你找出他们的国旗是否符合新的ISO标准。

输入格式:

输入的第一行包含数n和m( ( 1<=n,m<=100 ),其中n为行数,m为列数。接下来

是对旗的描述:以下N行中的每一行包含m个字符。每个字符是0到9之间的数字,代表相应正方形的颜色。

输出格式:

如果国旗符合标准就输出YES,否则输出NO。

题目描述

According to a new ISO standard, a flag of every country should have a chequered field n×mn×m , each square should be of one of 10 colours, and the flag should be «striped»: each horizontal row of the flag should contain squares of the same colour, and the colours of adjacent horizontal rows should be different. Berland's government asked you to find out whether their flag meets the new ISO standard.

输入输出格式

输入格式:

The first line of the input contains numbers nn and mm ( 1<=n,m<=1001<=n,m<=100 ), nn — the amount of rows, mm — the amount of columns on the flag of Berland. Then there follows the description of the flag: each of the following nn lines contain mmcharacters. Each character is a digit between 0 and 9, and stands for the colour of the corresponding square.

输出格式:

Output YES, if the flag meets the new ISO standard, and NO otherwise.

输入输出样例

输入样例#1: 复制

3 3
000
111
222
输出样例#1: 复制

YES
输入样例#2: 复制

3 3
000
000
111
输出样例#2: 复制

NO
输入样例#3: 复制

3 3
000
111
002
输出样例#3: 复制

NO
AC
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int n,m;
int map[][];
int main(){
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++){
string s;cin>>s;
for(int j=;j<m;j++)
map[i][j+]=s[j]-'';
}
for(int i=;i<=n;i++){
int now=map[i][];
for(int j=;j<=m;j++)
if(map[i][j]!=now){
cout<<"NO"<<endl;
return ;
}
}
int now=map[][];
for(int i=;i<=n;i++){
if(map[i][]==now){
cout<<"NO"<<endl;
return ;
}
now=map[i][];
}
cout<<"YES"<<endl;
}

 

最新文章

  1. 从网上找的 visual studio 的各个版本下载地址,vs2010/vs2012/vs2013带注册码
  2. 51nod DP 最大子段和
  3. (转)JS模块化编程之AMD规范
  4. Android无线调试
  5. C#元组示例详解
  6. Beaglebone Black&ndash; 智能家居控制系统 LAS - 网页服务器 Node.js 、Web Service、页面 和 TCP 请求转 UDP 发送
  7. as3中的多线程
  8. sed的选项与命令简要
  9. php 设置报错等级
  10. mongoose的virtual属性
  11. 从.git文件夹探析git实现原理
  12. Asp.net MVC WebApi项目的自动接口文档及测试功能打开方法
  13. [HDFS Manual] CH3 HDFS Commands Guide
  14. tap news:week5 0.0 create react app
  15. TouchSlide触屏滑动特效插件的使用
  16. 2. 跟踪标记 (Trace Flag) 3604, 3605 输出DBCC命令结果
  17. Currency Exchange 货币兑换 Bellman-Ford SPFA 判正权回路
  18. C#中图片切割,图片压缩,缩略图生成的代码
  19. Leetcode 483. Smallest Good Base
  20. [0] OpenCV_Notes - 琐碎

热门文章

  1. java使用Thumbnailator处理图片
  2. UVa 170 - Clock Patience
  3. sqlite学习笔记7:C语言中使用sqlite之打开数据库
  4. bzoj1503: [NOI2004]郁闷的出纳员(伸展树)
  5. NPAPI——实现非IE浏览器的类似ActiveX的本地程序(插件)调用
  6. BZOJ 4241 分块
  7. 算法入门经典-第七章 例题7-4-1 拓展 n皇后问题 回溯法
  8. NLog日志记录
  9. Sybase to Oracle Golden Gate
  10. ibatiS启动的异常 The content of elements must consist of well-formed character data or markup