Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u

Submit Status

Description

Valera is a little boy. Yesterday he got a huge Math hometask at school, so Valera didn't have enough time to properly learn the English alphabet for his English lesson. Unfortunately, the English teacher decided to have a test on alphabet today. At the test Valera got a square piece of squared paper. The length of the side equals n squares (n is an odd number) and each unit square contains some small letter of the English alphabet.

Valera needs to know if the letters written on the square piece of paper form letter "X". Valera's teacher thinks that the letters on the piece of paper form an "X", if:

  • on both diagonals of the square paper all letters are the same;
  • all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals.

Help Valera, write the program that completes the described task for him.

Input

The first line contains integer n (3 ≤ n < 300; n is odd). Each of the next n lines contains n small English letters — the description of Valera's paper.

Output

Print string "YES", if the letters on the paper form letter "X". Otherwise, print string "NO". Print the strings without quotes.

Sample Input

Input
5
xooox
oxoxo
soxoo
oxoxo
xooox
Output
NO
Input
3
wsw
sws
wsw
Output
YES
Input
3
xpx
pxp
xpe
Output
NO

Source

题意:只有两种不同的字符,对角线一种,非对角线一种,判断对角线的所有字符是否一样,非对角线的所有字符是否一样。
#include <iostream>
using namespace std;
int main()
{
int i,j,n;
char c[][];
cin>>n;
for(i=;i<n;i++)
cin>>c[i];
char tmp1=c[][];
char tmp2=c[][];
if(tmp1==tmp2)
{
cout<<"NO"<<endl;
return ;
}
int flag=;
for(i=;i<n;i++)
{for(j=;j<n;j++)
{
if(i==j||i+j==n-)
{
if(c[i][j]!=tmp1)
{
flag=;
break;
}
}
else
{
if(c[i][j]!=tmp2)
{
flag=;
break;
}
}if(!flag)
break;
}
}
if(flag)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return ;
}

CodeForces - 404A(模拟题)的更多相关文章

  1. CodeForces - 427B (模拟题)

    Prison Transfer Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Sub ...

  2. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  3. Codeforces 390A( 模拟题)

    Inna and Alarm Clock Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64 ...

  4. CodeForces 1B 模拟题。

    H - 8 Time Limit:10000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Statu ...

  5. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  6. Codeforces 767B. The Queue 模拟题

    B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...

  7. Codeforces Beta Round #7 B. Memory Manager 模拟题

    B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...

  8. Codeforces Beta Round #5 B. Center Alignment 模拟题

    B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...

  9. Codeforces Beta Round #3 C. Tic-tac-toe 模拟题

    C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone i ...

随机推荐

  1. Mybatis的ResultMap的使用

    本篇文章通过一个实际工作中遇到的例子开始吧: 工程使用Spring+Mybatis+Mysql开发.具体的业务逻辑很重,对象之间一层一层的嵌套.和数据库表对应的是大量的model类,而和前端交互的是V ...

  2. javascript设计模式-装饰模式

    装饰模式:在不改变原类(对象)和继承的情况下动态扩展对象功能,通过包装一个对象来实现一个新的具有原对象相同接口的新的对象.在设计原则中,有一条,多用组合,少用继承,装饰模式正是这一原则的体现. UML ...

  3. VirtualBox安装Fedora20

    工具/原料 Fedora20 32位版(必须是32位,VirtualBox不识别64位操作系统) Oracle VM VirtualBox 方法/步骤 1 搜索Oracle VM VirtualBox ...

  4. C++中debug和release的区别 . 转载

    vc中debug和release的不同 收藏  在使用VC开发软件的过程中,正当要享受那种兴奋的时候突然发现:release与debug运行结果不一致,甚至出错,而release又不方便调试,真的是当 ...

  5. hdu 2085 核反应堆

    看完题,想到用结构体存储高质点和低质点,然后打表存储<33的质点数量. #include<stdio.h> struct hilo { long long hi,lo; }; int ...

  6. glutBitmapCharacter及glBitmap在ATI显卡下无法正常显示的原因初探

    最近家里台式机的老显卡烧了,所以更换了ATI的HD6450显卡,却发现glutBitmapCharacter及glBitmap都无法正常显示字符,nviDIA和intel的显卡则一切正常. 发邮件咨询 ...

  7. PHP: Local 和 Global 作用域

    函数之外声明的变量拥有 Global 作用域,只能在函数以外进行访问. 函数内部声明的变量拥有 LOCAL 作用域,只能在函数内部进行访问. 下面的例子测试了带有局部和全局作用域的变量: 在上例中,有 ...

  8. cocos基础教程(13)使用Physicals代替Box2D和chipmunk

    1.   概述 游戏中模拟真实的世界是个比较麻烦的事情,通常这种事情都是交给物理引擎来做.首屈一指的是Box2D了,它几乎能模拟所有的物理效果.而chipmunk则是个更轻量的引擎,能够满足简单的物理 ...

  9. DLL注入之注册表

    0x00 唠叨 编写本系列文章纯属为了系统学习DLL注入的方法,所以很多方法可能已经过时,希望各位看官勿喷.当然若有更好的方法,希望不腻赐教.若本文有任何错的地方,也希望各位指正.谢谢! 0x01 适 ...

  10. 在Android的webview中定做js的alert,confirm和prompt对话框的方法

    在Android的webview中定制js的alert,confirm和prompt对话框的方法 http://618119.com/archives/2010/12/20/199.html 1.首先 ...