CodeForces - 404A(模拟题)
来源:互联网 发布:mac怎样看视频更省电 编辑:程序博客网 时间:2024/05/16 01:40
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[305][305]; cin>>n; for(i=0;i<n;i++) cin>>c[i]; char tmp1=c[0][0]; char tmp2=c[0][1]; if(tmp1==tmp2) { cout<<"NO"<<endl; return 0; } int flag=1; for(i=0;i<n;i++) {for(j=0;j<n;j++) { if(i==j||i+j==n-1) { if(c[i][j]!=tmp1) { flag=0; break; } } else { if(c[i][j]!=tmp2) { flag=0; break; } }if(!flag) break; } } if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0;}
- CodeForces - 404A(模拟题)
- Codeforces 390A( 模拟题)
- codeforces 116A Tram(模拟水题)
- CodeForces - 344A Magnets (模拟题)
- CodeForces 600A - Extract Numbers (模拟题)
- Codeforces 631A Interview【模拟水题】
- codeforces 691A 模拟
- Codeforces 67A【模拟】
- Codeforces 449A 模拟
- Codeforces 1A 【模拟】
- codeforces 855A 模拟
- codeforces 187A 模拟
- codeforces 416 A. Guess a number!(简单模拟题)
- Codeforces 330A Cakeminator(模拟)
- 模拟 之 Codeforces 416A
- CodeForces 651A:Joysticks【模拟】
- CodeForces 632A(反向模拟)
- 【CodeForces 651A】Joysticks 模拟
- Codeforces 389A (最大公约数)
- thrift数据结构
- Codeforces 389B(十字模拟)
- Codeforces 390A( 模拟题)
- 严谨的单例实现方案
- CodeForces - 404A(模拟题)
- CodeForces - 404B(模拟题)
- CodeForces - 405A
- Oracle的Package的作用及用法
- 打包软件的调研
- CodeForces - 405C
- CodeForces - 407A
- CodeForces - 407B
- CodeForces - 416A (判断大于小于等于 模拟题)