您的位置:首页 > 其它

Codeforces Round #237 Div.2 A

2014-05-11 16:07 274 查看
题目链接:http://codeforces.com/contest/404/problem/A

模拟题,第一次没有考虑对角线上的字符和其余地方的字符是相同的的情况,改掉后就OK了。
///2014.3.19
///Codeforces Round #237 Div.2
///A

#include <iostream>
#include <cstdio>
using namespace std;

char table[310][310];

int main()
{
// freopen("in","r",stdin);
// freopen("out","w",stdout);

int n;
cin>>n;
char a,b;
for(int i=1 ; i<=n ; i++){
for(int j=1 ; j<=n ; j++){
cin>>table[i][j];
}
}

a = table[1][1];
b = table[1][2];
bool is = true;
if( a==b )
is = false;
for(int i=1 ; i<=n ; i++){
if( !is ) break;
for(int j=1 ; j<=n ; j++){
if( i==j || i+j==n+1 ){
if( table[i][j]!=a ){
is = false;
break;
}
}
else{
if( table[i][j]!=b ){
is = false;
break;
}
}
}
}

if( is ) cout<<"YES"<<endl;
else cout<<"NO"<<endl;

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: