// スパゲティ #include using namespace std; int data[200][200]; // 落ち対策 int ord[3000][2]; int main(){ int i, j, k, l; int h,w,n; int x,y; cin >> h>>w; n=0; for (y=0;y> c),c<32); if (c=='#'){ n+=1; data[x][y]=n; ord[n][0]=x; ord[n][1]=y; } } if (n%2==1 || n==0){ goto l_no; } int vx,vy; for (vx=-w+1,vy=-h+1;vy memo(n+1,0); for (i=1;i<=n;i++){ x=ord[i][0]; y=ord[i][1]; if (memo[i]==0){ if (x+vx<0 || y+vy<0) goto l_cont; j= data[x+vx][y+vy]; if (j==0 || memo[j]!=0){ // HALT goto l_cont; } memo[j]=2; memo[i]=1; } } cout << "YES" << endl; return 0; l_cont: if (vx>=w-1){ vy++; vx=-w; } } l_no: cout << "NO" << endl; return 0; }