結果

問題 No.179 塗り分け
ユーザー 37zigen37zigen
提出日時 2020-02-19 14:26:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,087 bytes
コンパイル時間 1,911 ms
コンパイル使用メモリ 77,300 KB
実行使用メモリ 57,084 KB
最終ジャッジ日時 2024-04-16 21:00:56
合計ジャッジ時間 10,079 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
41,372 KB
testcase_01 AC 122 ms
41,928 KB
testcase_02 AC 123 ms
41,368 KB
testcase_03 AC 112 ms
41,496 KB
testcase_04 AC 120 ms
41,576 KB
testcase_05 AC 140 ms
44,292 KB
testcase_06 AC 122 ms
40,028 KB
testcase_07 WA -
testcase_08 AC 158 ms
45,688 KB
testcase_09 WA -
testcase_10 AC 129 ms
41,836 KB
testcase_11 AC 114 ms
41,532 KB
testcase_12 AC 156 ms
45,552 KB
testcase_13 AC 118 ms
41,296 KB
testcase_14 AC 121 ms
41,912 KB
testcase_15 AC 124 ms
41,568 KB
testcase_16 AC 131 ms
41,884 KB
testcase_17 AC 126 ms
41,276 KB
testcase_18 AC 143 ms
42,464 KB
testcase_19 AC 122 ms
42,084 KB
testcase_20 AC 160 ms
45,792 KB
testcase_21 AC 181 ms
45,128 KB
testcase_22 AC 166 ms
45,232 KB
testcase_23 AC 120 ms
41,832 KB
testcase_24 AC 176 ms
45,808 KB
testcase_25 AC 122 ms
41,892 KB
testcase_26 WA -
testcase_27 AC 203 ms
45,040 KB
testcase_28 WA -
testcase_29 AC 196 ms
45,808 KB
testcase_30 WA -
testcase_31 AC 197 ms
45,504 KB
testcase_32 AC 160 ms
45,688 KB
testcase_33 AC 190 ms
45,448 KB
testcase_34 WA -
testcase_35 AC 197 ms
46,152 KB
testcase_36 AC 113 ms
41,492 KB
testcase_37 AC 117 ms
41,456 KB
testcase_38 AC 116 ms
41,504 KB
testcase_39 AC 127 ms
41,424 KB
testcase_40 AC 118 ms
41,444 KB
testcase_41 AC 118 ms
40,076 KB
testcase_42 AC 106 ms
41,276 KB
testcase_43 AC 122 ms
41,884 KB
testcase_44 AC 137 ms
44,860 KB
testcase_45 AC 112 ms
41,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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