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.

Examples
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 <cstdio>
#include <iostream> using namespace std; int n,m; char map[][]; int main()
{
cin>>n>>m;
for(int i=;i<=n;i++)
{
cin>>map[i]+;
if(map[i][]==map[i-][])
{
cout<<"NO";
return ;
}
for(int j=;j<=m;j++)
{
if(map[i][j]!=map[i][j-])
{
cout<<"NO";
return ;
}
}
}
cout<<"YES";
return ;
}

AC日记——Flag Codeforces 16a的更多相关文章

  1. AC日记——codevs1688求逆序对

    AC日记--codevs1688求逆序对 锵炬 掭约芴巷 枷锤霍蚣 蟠道初盛 到被他尽情地踩在脚下蹂躏心中就无比的兴奋他是怎么都 ㄥ|囿楣 定要将他剁成肉泥.挫骨扬灰跟随着戴爷这么多年刁梅生 圃鳋 ...

  2. AC日记——Dynamic Problem Scoring codeforces 807d

    Dynamic Problem Scoring 思路: 水题: 代码: #include <cstdio> #include <cstring> #include <io ...

  3. AC日记——Periodic RMQ Problem codeforces 803G

    G - Periodic RMQ Problem 思路: 题目给一段序列,然后序列复制很多次: 维护序列很多次后的性质: 线段树动态开点: 来,上代码: #include <cstdio> ...

  4. AC日记——Sign on Fence Codeforces 484e

    E. Sign on Fence time limit per test 4 seconds memory limit per test 256 megabytes input standard in ...

  5. AC日记——Propagating tree Codeforces 383c

    C. Propagating tree time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  6. AC日记——Cards Sorting codeforces 830B

    Cards Sorting 思路: 线段树: 代码: #include <cstdio> #include <cstring> #include <iostream> ...

  7. AC日记——Sagheer and Nubian Market codeforces 812c

    C - Sagheer and Nubian Market 思路: 二分: 代码: #include <bits/stdc++.h> using namespace std; #defin ...

  8. AC日记——Sagheer, the Hausmeister codeforces 812b

    812B - Sagheer, the Hausmeister 思路: 搜索: 代码: #include <cstdio> #include <cstring> #includ ...

  9. AC日记——Sagheer and Crossroads codeforces 812a

    812A - Sagheer and Crossroads 思路: 模拟: 代码: #include <cstdio> #include <cstring> #include ...

随机推荐

  1. mysql 5.7安装密码校验插件validate_password

    在使用服务器插件之前,必须将它们加载到服务器中.MySQL支持在服务器启动和运行时加载插件.还可以在启动时控制加载插件的激活状态,并在运行时卸载它们.在加载插件时,可以从INFORMATION_SCH ...

  2. verilog 1995 VS 2001 part1模块声明的扩展

    1.模块声明的扩展 (1)端口声明(input/output/inout)同数据类型声明(reg /wire)放在同一语句中. (2)ANSI C风格的端口声明可以用于module/task/func ...

  3. linux中怎样关闭ICMP回应功能

    引用自:http://blog.csdn.net/qq844352155/article/details/49700121 linux中怎样关闭ICMP回应功能   输入:   echo 1 > ...

  4. Servlet注意事项

    注意事项 1.对于Servlet的应用程序的目录结构来说,若想让有些文件Servlet可以访问,而用户不能访问的时候,可以将其放置在WEB-INF目录下 2.ServletResponse中getwr ...

  5. 水题:CF16C-Monitor

    Monitor 题目描述 Reca company makes monitors, the most popular of their models is AB999 with the screen ...

  6. BZOJ 5336: [TJOI2018]party

    状压最长公共子序列的DP数组,一维最多K(15)个数,且相邻两个数的差不超过1,2^15种状态,预处理转移 #include<cstdio> #include<algorithm&g ...

  7. TextView设置缩略显示

    1.代码设置 textview.setSingleLine(); textview.setEllipsiz(TextUtils.TruncateAt.valueOf("END")) ...

  8. const用法归纳总结 C++

    非常好的一篇分析const的总结归纳, 在此谢谢原作者:http://blog.csdn.net/zcf1002797280/article/details/7816977 在普通的非 const成员 ...

  9. LPSTR LPCSTR LPWSTR LPCWSTR区别

    LPSTR   一个32位的指向字符串的指针    LPCSTR   一个32位的指向字符串常量的指针    LPWSTR   一个32位的指向unicode字符串的指针    LPCWSTR   个 ...

  10. php 图表的操作

    <?php $dir=dirname(__FILE__);//查找当前脚本所在路径 require $dir."/db.php";//引入mysql操作类文件 require ...