結果

問題 No.179 塗り分け
ユーザー 37zigen37zigen
提出日時 2020-02-19 14:26:49
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,087 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 74,212 KB
実行使用メモリ 59,388 KB
最終ジャッジ日時 2023-07-29 15:13:22
合計ジャッジ時間 11,373 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
56,112 KB
testcase_01 AC 118 ms
57,800 KB
testcase_02 AC 118 ms
55,992 KB
testcase_03 AC 117 ms
56,156 KB
testcase_04 AC 119 ms
55,936 KB
testcase_05 AC 136 ms
58,128 KB
testcase_06 AC 121 ms
55,872 KB
testcase_07 WA -
testcase_08 AC 164 ms
58,032 KB
testcase_09 WA -
testcase_10 AC 124 ms
56,256 KB
testcase_11 AC 125 ms
55,588 KB
testcase_12 AC 181 ms
58,744 KB
testcase_13 AC 118 ms
55,976 KB
testcase_14 AC 122 ms
55,624 KB
testcase_15 AC 116 ms
56,512 KB
testcase_16 AC 118 ms
56,304 KB
testcase_17 AC 118 ms
56,044 KB
testcase_18 AC 157 ms
55,904 KB
testcase_19 AC 136 ms
55,432 KB
testcase_20 AC 177 ms
58,624 KB
testcase_21 AC 177 ms
56,704 KB
testcase_22 AC 179 ms
58,840 KB
testcase_23 AC 125 ms
55,368 KB
testcase_24 AC 180 ms
57,804 KB
testcase_25 AC 127 ms
56,296 KB
testcase_26 WA -
testcase_27 AC 194 ms
58,612 KB
testcase_28 WA -
testcase_29 AC 209 ms
58,740 KB
testcase_30 WA -
testcase_31 AC 215 ms
58,468 KB
testcase_32 AC 177 ms
58,764 KB
testcase_33 AC 213 ms
58,596 KB
testcase_34 WA -
testcase_35 AC 226 ms
59,388 KB
testcase_36 AC 124 ms
55,952 KB
testcase_37 AC 118 ms
56,056 KB
testcase_38 AC 117 ms
56,004 KB
testcase_39 AC 119 ms
55,808 KB
testcase_40 AC 121 ms
56,192 KB
testcase_41 AC 118 ms
55,856 KB
testcase_42 AC 119 ms
56,284 KB
testcase_43 AC 130 ms
55,744 KB
testcase_44 AC 142 ms
58,756 KB
testcase_45 AC 120 ms
55,916 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