-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA_Flag.cpp
48 lines (42 loc) · 866 Bytes
/
A_Flag.cpp
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
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool check_key(map<int, int> m, int key)
{
if (m.find(key) == m.end())
return 0;
return 1;
}
int main(){
ll i,j,n,m;
char s[101][101];
while(cin>>n>>m){
for(i=0;i<n;i++){
for(j=0;j<m;j++){
cin>>s[i][j];
}
}
bool f=1;
for(i=1;i<n;i++){
for(j=0;j<m;j++){
if(s[i][j]==s[i-1][j]){
f=0;
break;
}
}
}
for(i=0;i<n;i++){
for(j=1;j<m;j++){
if(s[i][j]!=s[i][j-1]){
f=0;
break;
}
}
}
if(f==1)
cout<<"YES\n";
else
cout<<"NO\n";
}
return 0;
}