A. Valera and X

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
input
5
xooox
oxoxo
soxoo
oxoxo
xooox
output
NO
input
3
wsw
sws
wsw
output
YES
input
3
xpx
pxp
xpe
output
NO

题解:模拟。注意所有测试数据都是一个字母的情况。
例如:
3
aaa
aaa
aaa

answer:NO


代码:
 #include<stdio.h>
#include<stdbool.h>
#include<string.h>
#include<limits.h>
int i,j,n,m;
char a[][];
bool can[][]; int
pre()
{
memset(can,true,sizeof(can));
return ;
} int
main()
{
int f;
f=; pre();
scanf("%d",&n);
for(i=;i<=n;i++)
scanf("%s",&a[i]); for(i=;i<=(n >> );i++)
{
if(a[i][i-]!=a[][])
{
f=;
break;
}
if(a[n-i+][i-]!=a[][])
{
f=;
break;
}
if(a[i][n-i]!=a[][])
{
f=;
break;
}
if(a[n-i+][n-i]!=a[][])
{
f=;
break;
}
}
if(a[(n/)+][n/]!=a[][]) f=; if (f==) printf("NO\n");
else
{
f=;
for(i=;i<=(n/);i++)
{
can[i][i-]=false;
can[n-i+][i-]=false;
can[i][n-i]=false;
can[n-i+][n-i]=false;
}
can[(n/)+][n/]=false; for(i=;i<=n;i++)
for(j=;j<n;j++)
if (can[i][j])
{
if(a[i][j]!=a[][])
{
f=;
break;
}
}
if((f==)&&(a[][]!=a[][])) printf("YES\n");
else printf("NO\n"); } return ;
}
 
 

[Codeforces Round #237 (Div. 2)] A. Valera and X的更多相关文章

  1. Codeforces Round #237 (Div. 2) B题模拟题

    链接:http://codeforces.com/contest/404/problem/B B. Marathon time limit per test 1 second memory limit ...

  2. Codeforces Round #237 (Div. 2) A

    链接:http://codeforces.com/contest/404/problem/A A. Valera and X time limit per test 1 second memory l ...

  3. Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)

    B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard ...

  4. Codeforces Round #237 (Div. 2) B. Marathon(卡long long)

    题目:http://codeforces.com/contest/404/problem/B #include <iostream> #include <cstring> #i ...

  5. Codeforces Round #237 (Div. 2)

    链接 A. Valera and X time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inp ...

  6. Codeforces Round #216 (Div. 2) D. Valera and Fools

    题目链接:http://codeforces.com/contest/369/problem/D 注意题意:所有fools都向编号最小的fool开枪:但每个fool都不会笨到想自己开枪,所以编号最小的 ...

  7. codeforces Round #252 (Div. 2) C - Valera and Tubes

    贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #i ...

  8. Codeforces Round #252 (Div. 2) B. Valera and Fruits

    #include <iostream> #include <vector> #include <algorithm> #include <map> us ...

  9. Codeforces Round #252 (Div. 2) A - Valera and Antique Items

    水题 #include <iostream> #include <set> #include <vector> #include <algorithm> ...

随机推荐

  1. ubuntu 终端只显示当前目录名称

    修改.bashrc文件: 原来: #修改终端提示颜色 color_prompt=yes if [ "$color_prompt" = yes ]; then PS1='${debi ...

  2. 国威电话机WS824(5D)-3型调试文档--可以转行啦

    多了一万多搞的机器,花了我和同事们两三个晚上,最近还要打技术支持得到的经验... 可以转行作弱电啦啦~~~) 一,外线分组调试: 默认设置为所有内线端口可用1,2,13,14,15,16打出.(16个 ...

  3. Powershell创建数组

    在Powershell中创建数组可以使用逗号. PS C:Powershell> $nums=2,0,1,2 PS C:Powershell> $nums 2 0 1 2 对于连续的数字数 ...

  4. windows下重命名一个带有前缀"."dot字符的名字的错误问题

    如果用正常的右键重命名那么肯定会报错的,比如: 有一个名为project的文件,我想把它命名为.project,加了个前缀dot.然后window就报错了,弹出个对话框让“你必须输入一个文件名”.它可 ...

  5. Python partial函数

    以前都是摘录的其他网友的博客,很少是自己写的,学习阶段,多多学习.今天开始自己写了,首先写一下刚刚遇到的partial函数. 1.partial函数主要是对参数的改变,假如一个函数有两个参数,而其中一 ...

  6. 在 Ubuntu 12.04 上安装 GitLab6.0

    安装环境: 操作系统:    Ubuntu 12.4 LTS 英文 数据库:        mysql5.5.32 web服务器: nginx1.4.1 首先, 添加git和nginx的ppa,并升级 ...

  7. 第19讲- UI组件之_Button、checkbox、radio

    第19讲 UI组件之_Button.checkbox.radio 四.按钮Button Button继承自TextView,间接继承自View.当用户对按钮进行操作的时候,触发相应事件,如点击,触摸. ...

  8. MySql按日期时间段进行统计(前一天、本周、某一天、某个时间段)

    在mysql数据库中,常常会遇到统计当天的内容.例如,在user表中,日期字段为:log_time 统计当天 sql语句为: select * from user where date(log_tim ...

  9. (转)iOS7界面设计规范(7) - UI基础 - 交互性与反馈

    现在只是周日下午,可怎样都觉得整个周末就这样即将过去了,不免沮丧.看了好多集小丸子了,又不免觉得现在其实是在放暑假,可以一天一天的窝在家里做任何事,任何事.再上一篇iOS7设计规范,然后本周末就到这里 ...

  10. JMeter Building a Database Test Plan

    Building a Database Test Plan In this section, you will learn how to create a basic Test Planto test ...