-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path404A
51 lines (48 loc) · 1.09 KB
/
404A
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include<bits/stdc++.h>
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int,int>
#define vpi vector<pii>
#define mp unordered_map<char,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define ff first
#define ss second
#define nline "\n"
#define pf cout
#define MOD1 1000000007
#define MOD2 1000000009
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;cin>>n;
string str;
set<char>x,anything;
for (int i=0;i<n;i++)
{
cin>>str;
for(int j=0; j<n;j++){
if (i==j || i+j==n-1){
x.insert(str[j]);
}
else {
anything.insert(str[j]);
}
}
}
/*for(auto it:x){
pf<<it.begin()<<nline;}
for (auto iti:anything){
pf<<iti.begin()<<nline;
}*/
if (x.size()==1 && anything.size()==1 && *x.begin()!=*anything.begin()){ // significance of last condition is that ->
//as it is a set , it'll store only 1 count of each type ...so it should be begin() and no such significance of end()
pf<<"YES"<<nline;
}
else{
pf<<"NO"<<nline;
}
return 0;
}