結果

問題 No.179 塗り分け
ユーザー tsunabittsunabit
提出日時 2020-03-10 21:16:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 262 ms / 3,000 ms
コード長 1,268 bytes
コンパイル時間 3,197 ms
コンパイル使用メモリ 74,492 KB
実行使用メモリ 56,736 KB
最終ジャッジ日時 2023-09-30 21:25:37
合計ジャッジ時間 11,414 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,508 KB
testcase_01 AC 120 ms
55,788 KB
testcase_02 AC 117 ms
55,588 KB
testcase_03 AC 122 ms
56,120 KB
testcase_04 AC 121 ms
55,252 KB
testcase_05 AC 169 ms
56,024 KB
testcase_06 AC 142 ms
53,684 KB
testcase_07 AC 262 ms
56,012 KB
testcase_08 AC 152 ms
55,860 KB
testcase_09 AC 158 ms
56,140 KB
testcase_10 AC 148 ms
55,452 KB
testcase_11 AC 149 ms
55,780 KB
testcase_12 AC 152 ms
55,836 KB
testcase_13 AC 122 ms
55,788 KB
testcase_14 AC 126 ms
56,292 KB
testcase_15 AC 120 ms
56,164 KB
testcase_16 AC 119 ms
55,544 KB
testcase_17 AC 121 ms
56,008 KB
testcase_18 AC 148 ms
55,860 KB
testcase_19 AC 147 ms
55,992 KB
testcase_20 AC 151 ms
56,440 KB
testcase_21 AC 165 ms
53,736 KB
testcase_22 AC 194 ms
54,020 KB
testcase_23 AC 147 ms
55,768 KB
testcase_24 AC 154 ms
56,176 KB
testcase_25 AC 164 ms
56,012 KB
testcase_26 AC 149 ms
55,440 KB
testcase_27 AC 151 ms
56,188 KB
testcase_28 AC 149 ms
55,744 KB
testcase_29 AC 151 ms
56,116 KB
testcase_30 AC 151 ms
55,640 KB
testcase_31 AC 153 ms
56,056 KB
testcase_32 AC 149 ms
56,296 KB
testcase_33 AC 155 ms
56,072 KB
testcase_34 AC 150 ms
56,424 KB
testcase_35 AC 152 ms
56,736 KB
testcase_36 AC 121 ms
56,200 KB
testcase_37 AC 122 ms
56,008 KB
testcase_38 AC 120 ms
55,952 KB
testcase_39 AC 120 ms
56,280 KB
testcase_40 AC 120 ms
56,216 KB
testcase_41 AC 120 ms
55,680 KB
testcase_42 AC 120 ms
56,128 KB
testcase_43 AC 147 ms
55,908 KB
testcase_44 AC 173 ms
56,064 KB
testcase_45 AC 125 ms
55,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class No179 {
	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 k = 0; k < (H - 1) * W + W; k++) {
					int y = k / W;
					int x = k % W;
						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;
								flag = true;
							}else {
								flag = false;
								break;
							}
						}
					}
					if(flag) {
						System.out.println("YES");
						System.exit(0);
					}
				}

			}
		System.out.println("NO");
	}
}
0