A. Flag

2024-08-28 07:18
文章标签 flag

本文主要是介绍A. Flag,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

A. Flag
time limit per test
2 seconds
memory limit per test
64 megabytes
input
standard input
output
standard output

According to a new ISO standard, a flag of every country should have a chequered field n?×?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.

Input

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

Output

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

Sample test(s)
input
3 3
000
111
222
output
YES
input
3 3
000
000
111
output
NO
input
3 3
000
111
002
output
NO

相邻两行是不同的字符
每行都是一样的字符
/* ***********************************************

************************************************ */

#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 1<<30
#define maxn 10000+10
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;

bool cmp(int a,int b){
return a>b;
}
string s;
int main()
{
#ifndef ONLINE_JUDGE
//freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int n,m;
while(cin>>n>>m){
s="";
string t="";
int mark=0;
for(int i=1;i<=n;i++){
if(i==1){
cin>>s;
for(int i=1;i<m;i++)
if(s[i]!=s[i-1])mark=1;
}
else {
cin>>t;
if(t==s){
mark=1;
}
if(t!=s){
for(int i=1;i<m;i++)
if(t[i]!=t[i-1])mark=1;
}
s=t;
}
}
if(mark)cout<<"NO";
else cout<<"YES";
}
return 0;
}

这篇关于A. Flag的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1114089

相关文章

GNU/Linux - Open函数使用的O_CLOEXEC flag

在 Linux 中,“O_CLOEXEC ”标志与 “open ”系统调用一起使用,用于指定在使用 “exec ”系列函数(如 “execve”、“execl ”等)执行新程序时,“open ”返回的文件描述符应自动关闭。 In Linux, the `O_CLOEXEC` flag is used with the `open` system call to specify that

使用 GZCTF 结合 GitHub 仓库搭建独立容器与动态 Flag 的 CTF 靶场以及基于 Docker 的 Web 出题与部署

写在前面 关于 CTF 靶场的搭建(使用 CTFd 或者 H1ve)以及 AWD 攻防平台的搭建,勇师傅在前面博客已经详细写过,可以参考我的《网站搭建》专栏,前段时间玩那个 BaseCTF,发现它的界面看着挺不错的,了解到也是一个开源项目-GZCTF,网上未见有这方面的详细介绍,看了下网上都只是简单说了下怎么搭出 GZCTF 这个靶场的界面,然而对于后续题目的部署并未进行详细的介绍与说明,因此这

如何解决Docker启动时报Status: unknown flag: --graph问题

最近在进行Docker环境迁移时,用二制对Docker进行了重新安装,一切配置好之后,启动Docker时,服务启动不起来,使用journalctl -xe命令查看,报出以下错误: [root@app docker]# journalctl -xe8月 25 14:25:46 app dockerd[3269]: Status: unknown flag: --graph8月 25 14:25

18年的第一个flag

2018年新年新计划 新的一年已经到来了,我的新年计划已经迟到这么多天,直到今天,我才醒悟过来,对自己以后的生活有了更清晰明确的认识和努力方向。在浑浑噩噩中度过17年,不知道是因为读了这么多年书,读硕士对自己放松要求了还是别的原因,竟然忘记了曾经那个积极努力向上的我,变得颓废,喜欢抱怨,喜欢推卸责任,今天,终于醒悟,我要的是做我自己。17年最后的事情是签了一份测试开发的工作,骨子里喜欢奋斗,

不一样的SYSTEM APP(SYSTEM flag和system_prop区别)

1.问题引入 在Android开发中, 1)Framework中PackageManager扫包后,会把app归类为SYSTEM, SYSTEM_EXT, PRIVILEGED 类别. 2)同样的, SeAndroid也会把APP归类程platform_app, system_app, untrusted_app(甚至还有其他,mediaprovider,gmscore_app). flag

记录Intent的几种Flag

写的比较乱,只是作为自己的一个笔记,参考价值不高。 1. FLAG_ACTIVITY_NEW_TASK标签测试 2. FLAG_ACTIVITY_CLEAR_TOP标签测试 3. FLAG_ACTIVITY_CLEAR_TASK标签测试 4. FLAG_ACTIVITY_SINGLE_TOP标签测试 首先是新建两个Activity,分别为MainActivity和Se

达梦8 探寻达梦排序原理:新排序机制(SORT_FLAG=1)

测试版本:--03134283938-20221019-172201-20018 达梦的排序机制由四个dm.ini参数控制: #maximum sort buffer size in Megabytes ,有效值范围(1~2048) SORT_BUF_SIZE = 100 #maximum sort blk size i

IRP结构体之Flag成员

IRP_NOCACHE //表示I/O请求从存储的媒介而不是高速缓存中读取数据IRP_PAGING_IO //表示此时执行内存页的I/O操作IRP_MOUNT_COMPLETION //卷挂载操作完成IRP_SYNCHRONOUS_API //该操作是一个同步分页I/O操作。IRP_ASSOCIATED_IR

Android Intent.FLAG_NEW_TASK 和其他标记的解释

本文转载自http://www.cnblogs.com/xiaoQLu/archive/2012/07/17/2595294.html。 本文大部分参考自 http://blog.csdn.net/mayingcai1987/article/details/6200909 ,对原文中的讲解FLAG_NEW_TASK地方加了一些自己的观点,用红色标记 1. Task是包含一系列Activity