#include<iostream> #include<cmath> #include<cstring> #include<algorithm> using namespace std; char a[305][305]; int main() { int i,j,k,m,n,ans; while(cin>>k) { ans=0;int temp=0,s=0; for(i=1;i<=k;i++) for(j=1;j<=k;j++) cin>>a[i][j]; for(i=2;i<=k;i++) if(a[i][i]==a[1][1]&&a[i][k-i+1]==a[1][k]) continue; else {ans=1;break;} //判断对角线是否相等 for(i=1;i<=k;i++) for(j=1;j<=k;j++) if(i==j||i+j==k+1)continue; else if(a[i][j]!=a[1][2]){temp=1;} //对角线外的元素是否相等 if(a[1][1]==a[1][2])s=1; //判断对角线和对角线外的元素是否一样 if(ans||temp||s)cout<<"NO"<<endl; else if(ans==0&&temp==0&&s==0)cout<<"YES"<<endl; } }
Codeforces Round #237 (Div. 2) A. Valera and X(模拟题)
最新推荐文章于 2022-11-22 23:15:14 发布