結果

問題 No.179 塗り分け
ユーザー YamaKasaYamaKasa
提出日時 2018-07-26 18:41:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,182 bytes
コンパイル時間 3,175 ms
コンパイル使用メモリ 74,248 KB
実行使用メモリ 58,708 KB
最終ジャッジ日時 2023-09-13 18:44:50
合計ジャッジ時間 15,007 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 120 ms
56,620 KB
testcase_02 WA -
testcase_03 AC 117 ms
56,212 KB
testcase_04 WA -
testcase_05 AC 184 ms
57,452 KB
testcase_06 WA -
testcase_07 AC 183 ms
56,176 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 304 ms
57,520 KB
testcase_13 AC 124 ms
55,928 KB
testcase_14 AC 124 ms
56,220 KB
testcase_15 AC 119 ms
56,160 KB
testcase_16 WA -
testcase_17 AC 119 ms
56,100 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 274 ms
57,460 KB
testcase_21 AC 263 ms
57,240 KB
testcase_22 AC 365 ms
57,200 KB
testcase_23 WA -
testcase_24 AC 299 ms
57,604 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 283 ms
56,660 KB
testcase_28 WA -
testcase_29 AC 284 ms
57,288 KB
testcase_30 WA -
testcase_31 AC 302 ms
57,204 KB
testcase_32 WA -
testcase_33 AC 327 ms
57,352 KB
testcase_34 WA -
testcase_35 AC 303 ms
57,764 KB
testcase_36 AC 121 ms
56,440 KB
testcase_37 AC 117 ms
56,352 KB
testcase_38 AC 118 ms
55,844 KB
testcase_39 AC 118 ms
56,028 KB
testcase_40 AC 117 ms
55,584 KB
testcase_41 AC 118 ms
56,140 KB
testcase_42 AC 118 ms
55,840 KB
testcase_43 AC 158 ms
56,880 KB
testcase_44 AC 188 ms
57,200 KB
testcase_45 AC 122 ms
56,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int H = scan.nextInt();
		int W = scan.nextInt();
		char c[][] = new char[H][W];
		for(int i = 0; i < H; i++) {
			String s = scan.next();
			for(int j = 0; j < W; j++) {
				c[i][j] = s.charAt(j);
			}
		}
		scan.close();
		boolean [][]s = new boolean[H][W];
		boolean flag = false;
		for(int dy = -H; dy <= H; dy++) {
			for(int dx = -W; dx <= W; dx++) {
				if(dy == 0 && dx == 0) {
					continue;
				}



				for(int i = 0; i < H; i++) {
					for(int j = 0; j < W; j++) {
						s[i][j] =false;
					}
				}

				for(int y = 0; y < H; y++) {
					for(int x = 0; x < W; x++) {
						if(c[y][x] == '#' && s[y][x] == false) {
							s[y][x] = true;
							if(y + dy < 0 || y + dy >= H || x + dx < 0 || x + dx >= W) {
								flag = false;
								break;
							}

							if(c[y + dy][x + dx] == '#' && s[y + dy][x + dx] == false) {
								s[y + dy][x + dx] = true;
							}else {
								flag = false;
								break;
							}
						}

					}
				}
			}
		}
		if(flag) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}
}
0