結果

問題 No.179 塗り分け
ユーザー uafr_csuafr_cs
提出日時 2015-08-06 19:08:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,432 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 77,580 KB
実行使用メモリ 55,908 KB
最終ジャッジ日時 2024-04-10 12:43:42
合計ジャッジ時間 15,771 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
53,008 KB
testcase_01 AC 116 ms
54,000 KB
testcase_02 AC 120 ms
54,200 KB
testcase_03 AC 121 ms
54,188 KB
testcase_04 AC 119 ms
53,984 KB
testcase_05 AC 281 ms
54,568 KB
testcase_06 AC 155 ms
54,808 KB
testcase_07 WA -
testcase_08 AC 123 ms
52,824 KB
testcase_09 AC 161 ms
54,508 KB
testcase_10 AC 245 ms
55,592 KB
testcase_11 AC 224 ms
55,908 KB
testcase_12 AC 400 ms
55,728 KB
testcase_13 AC 123 ms
54,136 KB
testcase_14 AC 126 ms
54,116 KB
testcase_15 AC 116 ms
52,816 KB
testcase_16 AC 128 ms
54,240 KB
testcase_17 AC 112 ms
54,208 KB
testcase_18 AC 379 ms
55,588 KB
testcase_19 AC 309 ms
54,856 KB
testcase_20 AC 484 ms
54,952 KB
testcase_21 AC 516 ms
55,396 KB
testcase_22 AC 450 ms
54,728 KB
testcase_23 AC 384 ms
55,268 KB
testcase_24 AC 440 ms
55,384 KB
testcase_25 AC 322 ms
55,264 KB
testcase_26 AC 328 ms
55,296 KB
testcase_27 AC 500 ms
55,544 KB
testcase_28 AC 392 ms
55,384 KB
testcase_29 AC 515 ms
55,452 KB
testcase_30 AC 347 ms
55,736 KB
testcase_31 AC 501 ms
55,108 KB
testcase_32 AC 351 ms
55,312 KB
testcase_33 AC 552 ms
55,684 KB
testcase_34 AC 320 ms
55,500 KB
testcase_35 AC 538 ms
55,552 KB
testcase_36 AC 119 ms
54,204 KB
testcase_37 AC 117 ms
54,000 KB
testcase_38 AC 108 ms
52,996 KB
testcase_39 AC 116 ms
54,124 KB
testcase_40 AC 120 ms
54,100 KB
testcase_41 AC 117 ms
54,284 KB
testcase_42 AC 116 ms
54,360 KB
testcase_43 AC 175 ms
54,392 KB
testcase_44 AC 257 ms
55,028 KB
testcase_45 AC 144 ms
54,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Set;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int H = sc.nextInt();
		final int W = sc.nextInt();
		
		boolean[][] fields = new boolean[H][W];
		for(int i = 0; i < H; i++){
			char[] inputs = sc.next().toCharArray();
			for(int j = 0; j < W; j++){
				fields[i][j] = inputs[j] == '#';
			}
		}
		
		boolean[][] checked = new boolean[H][W];
		
		for(int dy = -(H - 1); dy < H; dy++){
			for(int dx = -(W - 1); dx < W; dx++){
				if(dx == 0 && dy == 0){ continue; }
				
				for(int i = 0; i < H; i++){
					for(int j = 0; j < W; j++){
						checked[i][j] = false;
					}
				}
				
				
				for(int y = 0; y < H; y++){
					for(int x = 0; x < W; x++){
						final int nx = x + dx;
						final int ny = y + dy;
						if(nx < 0 || nx >= W || ny < 0 || ny >= H){ continue; }
						
						if(checked[y][x] || checked[ny][nx]){ continue; }
						if(fields[y][x] && fields[ny][nx]){
							checked[y][x] = checked[ny][nx] = true;
						}
					}
				}
				
				boolean flg = true;
				for(int i = 0; i < H; i++){
					for(int j = 0; j < W; j++){
						if(fields[i][j] && !checked[i][j]){
							flg = false;
						}
					}
				}
				
				if(flg){
					System.out.println("YES");
					return;
				}
			}
		}
		
		System.out.println("NO");
	}
	
}
0