CodeForces 404A 手速题

//CodeForces 404A

 1 #include "iostream"
 2 #include "cstdio"
 3 #include "cstring"
 4 #include "algorithm"
 5 using namespace std;
 6 char mat[310][310];
 7 int n;
 8 bool check_1()
 9 {
10     int i;
11     char c = mat[1][1];
12     for(i = 1; i <= n; ++i) {
13         if(c != mat[i][i] || c != mat[i][n + 1 - i])
14             return 0;
15     }
16     return 1;
17 }
18 
19 bool check_2()
20 {
21     int i, j;
22     char c = mat[1][2];
23     for(i = 1; i <= n; ++i) {
24         for(j = 1; j <= n; ++j) {
25             if(i == j || n + 1 - i == j)
26                 continue;
27             if(c != mat[i][j])
28                 return 0;
29         }
30     }
31     return 1;
32 }
33 
34 int main()
35 {
36     int i, j;
37     scanf("%d", &n);
38     for(i = 1; i <= n; ++i)
39         scanf("%s", mat[i] + 1);
40     if(mat[1][1] != mat[1][2] && check_1() && check_2())
41         printf("YES
");
42     else
43         printf("NO
");
44 }
原文地址:https://www.cnblogs.com/AC-Phoenix/p/4299069.html