#include #include #include #include #include #include #include using namespace std; int main(){ int h,w; string in; int data[50][50]; int data2[50][50]; int lowy = 999; int lowx = 999; int highy = -1; int highx = -1; int ysize,xsize; bool check; cin >> h >> w; for(int iy=0; iy> in; for(int ix=0; ix highy){ highy = iy; } if(ix > highx){ highx = ix; } }else{ data[iy][ix] = 0; } } } if(lowy == 999){ cout << "NO" << endl; return 0; } ysize = highy - lowy; xsize = highx - lowx; for(int ysizei=0; ysizei<=ysize; ysizei++){ for(int xsizei=-xsize; xsizei<=xsize; xsizei++){ //初期化 for(int iy=0; iy= h || ix+xsizei < 0 || ix+xsizei >= w || data2[iy+ysizei][ix+xsizei] == 0){ check = false; iy = h; break; }else{ data2[iy+ysizei][ix+xsizei] = 0; } } } } //cout << ysizei << "," << xsizei << " " << check << endl; if(check){ ysizei = ysize; break; } } } } if(check){ cout << "YES" << endl; }else{ cout << "NO" << endl; } return 0; }