Flag(173)

 avatar
jackoup
c_cpp
10 months ago
618 B
4
Indexable
CodeForces
#include <iostream>
#include <vector>
using namespace std;
void fio() {
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
}

int main() {
    fio();
    int n;cin>>n;
    int m;cin>>m;
    char ans= ' ';
    for(int i =0;i<n;i++) {
        string myInput;cin>>myInput;
        if( i != 0 && myInput[0] == ans){
            cout<<"NO";
            return 0;
        }
        for(int j =1 ;j<m;j++) {
            if(myInput[j] != myInput[0]){
                cout<<"NO";
                return 0;
            }
        }
        ans = myInput[0];
    }
    cout<<"YES";
    return 0;
}
Editor is loading...
Leave a Comment