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 ...
随机推荐
- 从svn服务器自动同步到另一台服务器
需求场景 A commit B post-commit C (workstation) --------------> (svn server) ---------------------> ...
- BZOJ-1207 打鼹鼠 DP(LIS)
1207: [HNOI2004]打鼹鼠 Time Limit: 10 Sec Memory Limit: 162 MB Submit: 2276 Solved: 1116 [Submit][Statu ...
- 【poj2186】 Popular Cows
http://poj.org/problem?id=2186 (题目链接) 题意 给出一个n个点m条边的有向图,求其中没有出度强连通分量所包含的点有几个 Solution 其实这道题的题解已经在“题意 ...
- 【poj3348】 Cows
http://poj.org/problem?id=3348 (题目链接) 题意 给出平面上n个点,以这n个点中的一些围成的多边形面积 div 50的最大值. Solution 凸包求面积. 很好做, ...
- 轻量级应用开发之(02)UIView
一 控件 1.屏幕上的所有UI元素都叫做控件(也有叫做视图.组件)比如按钮(UIButton).文本(UILabel)都是控件. 2.控件的共同属性有哪些? 尺寸,位置,背景色 3. 苹果将控件的共同 ...
- poj1631Bridging signals(最长单调递增子序列 nlgn)
Bridging signals Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 12251 Accepted: 6687 ...
- [Python] Python 之 __new__() 方法与实例化
__new__() 是在新式类中新出现的方法,它作用在构造方法建造实例之前,可以这么理解,在 Python 中存在于类里面的构造方法 __init__() 负责将类的实例化,而在 __init__() ...
- 修改host
需修改手机/etc/hosts文件.将” 118.194.60.190 域名” 添加 手机的/etc/hosts文件.手机需有root权限,操作如下:1. C:\Documents and Setti ...
- TFS 配置 报表权限问题
通过[项目门户网站]访问,却被提示ReportService权限不足时, 提示:处理报表时出错. (rsProcessingAborted) 对数据集 “dsiteration” 执行查询失败 同样 ...
- l来自wentao:项目加入缓存(redis),实时调试时用 -----可视化缓存,flushdb
下文来自segmentfault,网站:一个交流网站:https://segmentfault.com/ 在做一个项目时如果加入缓存(例如redis),我如何进行实时调试呢? 缓存 高并发 架构 gz ...