CodeForces - 404A(模拟题)
Time Limit: 1000MS | Memory Limit: 262144KB | 64bit IO Format: %I64d & %I64u |
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
5
xooox
oxoxo
soxoo
oxoxo
xooox
NO
3
wsw
sws
wsw
YES
3
xpx
pxp
xpe
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(模拟题)的更多相关文章
- CodeForces - 427B (模拟题)
Prison Transfer Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Sub ...
- CodeForces - 404B(模拟题)
Marathon Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Sta ...
- Codeforces 390A( 模拟题)
Inna and Alarm Clock Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64 ...
- CodeForces 1B 模拟题。
H - 8 Time Limit:10000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Statu ...
- Educational Codeforces Round 2 A. Extract Numbers 模拟题
A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...
- Codeforces 767B. The Queue 模拟题
B. The Queue time limit per test:1 second memory limit per test:256 megabytes input:standard input o ...
- Codeforces Beta Round #7 B. Memory Manager 模拟题
B. Memory Manager 题目连接: http://www.codeforces.com/contest/7/problem/B Description There is little ti ...
- Codeforces Beta Round #5 B. Center Alignment 模拟题
B. Center Alignment 题目连接: http://www.codeforces.com/contest/5/problem/B Description Almost every tex ...
- Codeforces Beta Round #3 C. Tic-tac-toe 模拟题
C. Tic-tac-toe 题目连接: http://www.codeforces.com/contest/3/problem/C Description Certainly, everyone i ...
随机推荐
- CentOS下crontab执行java程序
阿里云CentOS收不到邮件 在crontab里配置执行脚本,脚本用来执行java程序,死活不执行.单独执行脚本可以运行. 查看crontab的日志文件,/var/log/cron,发现没有收到cro ...
- BZOJ-1228 E&D 博弈SG+找啊找啊找规律
讨厌博弈,找规律找半天还是错的.... 1228: [SDOI2009]E&D Time Limit: 10 Sec Memory Limit: 162 MB Submit: 666 Solv ...
- 记录一次MVC 3.0错误 HTTP 404您正在查找的资源(或者它的一个依赖项)可能已被移除,或其名称已更改,或暂时不可用。请检查以下 URL 并确保其拼写正确。
在部署到IIS7时,MVC3报了一个找不到资源的错误,文件肯定是有的,而且页面是肯定报错的,也就说内部运行错误了,而MVC把错误没有抛出来而已: 所以对症下药,发觉我的项目里面用了rexs进行多语言, ...
- git 提交时保存 帐号密码
在相应的文件夹上右键 Tortiusegit->settings->gig 点击 第1个按钮 Edit local .git/config 在打开的文档里 url = http://xx. ...
- nuget pack
nuget spec nuget setApiKey yourkeynuget pack PluginMvc.Framework.csproj -Prop Configuration=Releasen ...
- JS实现上传本地图片前先预览
<style type="text/css"> #preview /*这个就是预览的DIV的ID*/ { filter:progid:DXImageTransform. ...
- Socket网络编程(3)--两端通信
上篇博文:http://www.cnblogs.com/wolf-sun/p/3329558.html 介绍了客户端连接服务端,一对一,多对一的情况,下面实现服务器接收消息的功能.LZ这些弄的比较慢, ...
- C++标准库异常类
C++标准库异常类 2012-12-24 16:27 5269人阅读 评论(1) 收藏 举报 分类: c/c++(36) C++标准库异常类继承层次中的根类为exception,其定义在excep ...
- 第三方平台正式支持接入微信公众平台JS-SDK
之前微信公众平台面向开发者开放微信内网页开发工具包,现在第三方平台也能正式支持接入微信公众平台JS-SDK了,第三方平台可以在获得公众号的授权后,通过JS-SDK帮助公众号开发和实现网页业务. 公众号 ...
- nginx负载均衡 加权轮询和ip_hash
下面给大家总结了几种真正的nginx负载均衡的功能了,在此我们加了一个权重判断法就是根据nginx负载的状态实现分配访问用户到权重值少的机器了,具体配置如下. nginx为后端web服务器(apach ...