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 ...
随机推荐
- [NOIP2010] 提高组 洛谷P1541 乌龟棋
题目背景 小明过生日的时候,爸爸送给他一副乌龟棋当作礼物. 题目描述 乌龟棋的棋盘是一行N个格子,每个格子上一个分数(非负整数).棋盘第1格是唯一的起点,第N格是终点,游戏要求玩家控制一个乌龟棋子从起 ...
- iOS项目开发知识点
前言部分 注:本文并非绝对原创 大部分内容摘自 http://blog.csdn.net/hengshujiyi/article/details/20943045 文中有些方法可能已过时并不适用于现在 ...
- html5新标签转
HTML 5 是一个新的网络标准,目标在于取代现有的 HTML 4.01, XHTML 1.0 and DOM Level 2 HTML 标准.它希望能够减少浏览器对于需要插件的丰富性网络应用服务(p ...
- c/c++细节知识整理
这篇文章总结了部分c/c++琐碎的细节知识. 目录如下: (一)bool类型 知识点出处较多,无法一一列举,向原作者致敬. (一)bool类型 在c99标准以前,c语言并没有定义bool类型.如果需要 ...
- hdu 2045 不容易系列之(3)—— LELE的RPG难题
解题思路: f(n)=1,2,.....n-2,n-1,n 前n-2个已经涂好,那么n-1有两种可能 1.n-1与n-2和1 的颜色都不同 1 粉, n-2 红, n-1 绿. 那么n的颜色 ...
- 改变字典内的value
import re,os limit = "8000" username = "liuhuihuang" with open("users_dict& ...
- sencha touch pull-refresh-panel 面板下拉刷新
转自:http://www.cnblogs.com/mlzs/archive/2013/06/04/3117518.html 此效果手机未测试,目测没问题,我是搬运工... 演示地址:http://s ...
- JS面试题及答案总结
1. 截取字符串abcdefg的efg <div id="test">abcdefg</div> var mytext=document.getEleme ...
- .NET平台上的Memcached客户端介绍
早上接到一个任务,需要对Linux服务器的Memcached的update操作进行性能测试,我发现我是一个典型的“手里拿着锤子, 就把所有问题都当成钉子”的人.我第一个念头就是,上Memcached的 ...
- WPF捕捉Windows关机事件
private const int SC_SCREENSAVE = 0xF140; private const int WM_QUERYENDSESSION = 0x0011; private boo ...