Codeforces Round #237 Div.2 A

题目链接:http://codeforces.com/contest/404/problem/A

模拟题,第一次没有考虑对角线上的字符和其余地方的字符是相同的的情况,改掉后就OK了。

 1 ///2014.3.19
 2 ///Codeforces Round #237 Div.2
 3 ///A
 4 
 5 #include <iostream>
 6 #include <cstdio>
 7 using namespace std;
 8 
 9 char table[310][310];
10 
11 int main()
12 {
13     // freopen("in","r",stdin);
14     // freopen("out","w",stdout);
15 
16     int n;
17     cin>>n;
18     char a,b;
19     for(int i=1 ; i<=n ; i++){
20         for(int j=1 ; j<=n ; j++){
21             cin>>table[i][j];
22         }
23     }
24 
25     a = table[1][1];
26     b = table[1][2];
27     bool is = true;
28     if( a==b )
29         is = false;
30     for(int i=1 ; i<=n ; i++){
31         if( !is ) break;
32         for(int j=1 ; j<=n ; j++){
33             if( i==j || i+j==n+1 ){
34                 if( table[i][j]!=a ){
35                     is = false;
36                     break;
37                 }
38             }
39             else{
40                 if( table[i][j]!=b ){
41                     is = false;
42                     break;
43                 }
44             }
45         }
46     }
47 
48     if( is ) cout<<"YES"<<endl;
49     else cout<<"NO"<<endl;
50 
51     return 0;
52 }

 

posted @ 2014-03-20 21:29  basement_boy  阅读(148)  评论(0编辑  收藏  举报