結果

問題 No.179 塗り分け
コンテスト
ユーザー 37zigen
提出日時 2020-02-19 14:26:49
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 1,087 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,642 ms
コンパイル使用メモリ 87,384 KB
実行使用メモリ 48,304 KB
最終ジャッジ日時 2026-09-11 18:43:26
合計ジャッジ時間 7,508 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 34 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		char[][] m=new char[H][W];
		for(int i=0;i<H;++i) {
			m[i]=sc.next().toCharArray();
		}
		for(int dh=0;dh<H;++dh) {
			for(int dw=0;dw<W;++dw) {
				if(dh==0&&dw==0)continue;
				boolean flag=true;
				int[][] rec=new int[H][W];
				for(int h=0;h<H;++h) {
					for(int w=0;w<W;++w) {
						if(m[h][w]=='.')continue;
						if(rec[h][w]!=0)continue;
						int nh=h+dh;
						int nw=w+dw;
						if(nh>=H||nw>=W) {
							flag=false;
							continue;
						}
						if(rec[nh][nw]==2) {
							flag=false;
							continue;
						}
						flag&=m[nh][nw]=='#';
						rec[h][w]=1;
						rec[nh][nw]=2;
					}
				}
				if(flag) {
					System.out.println("YES");
					return;
				}
			}
		}
		System.out.println("NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0