結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,024 KB
testcase_01 AC 131 ms
53,856 KB
testcase_02 AC 130 ms
54,144 KB
testcase_03 AC 116 ms
53,132 KB
testcase_04 AC 126 ms
54,204 KB
testcase_05 AC 156 ms
54,636 KB
testcase_06 AC 117 ms
53,076 KB
testcase_07 WA -
testcase_08 AC 180 ms
54,612 KB
testcase_09 WA -
testcase_10 AC 136 ms
53,984 KB
testcase_11 AC 135 ms
53,848 KB
testcase_12 AC 207 ms
54,944 KB
testcase_13 AC 128 ms
54,088 KB
testcase_14 AC 131 ms
54,172 KB
testcase_15 AC 123 ms
54,160 KB
testcase_16 AC 127 ms
54,016 KB
testcase_17 AC 115 ms
53,336 KB
testcase_18 AC 159 ms
54,296 KB
testcase_19 AC 160 ms
54,364 KB
testcase_20 AC 205 ms
55,040 KB
testcase_21 AC 175 ms
54,648 KB
testcase_22 AC 189 ms
54,868 KB
testcase_23 AC 134 ms
54,056 KB
testcase_24 AC 191 ms
54,900 KB
testcase_25 AC 158 ms
54,424 KB
testcase_26 WA -
testcase_27 AC 197 ms
54,868 KB
testcase_28 WA -
testcase_29 AC 208 ms
54,248 KB
testcase_30 WA -
testcase_31 AC 213 ms
54,904 KB
testcase_32 AC 190 ms
54,976 KB
testcase_33 AC 214 ms
55,028 KB
testcase_34 WA -
testcase_35 AC 221 ms
54,848 KB
testcase_36 AC 128 ms
53,836 KB
testcase_37 AC 114 ms
53,256 KB
testcase_38 AC 129 ms
54,224 KB
testcase_39 AC 127 ms
54,352 KB
testcase_40 AC 131 ms
54,124 KB
testcase_41 AC 125 ms
53,996 KB
testcase_42 AC 115 ms
53,140 KB
testcase_43 AC 152 ms
54,356 KB
testcase_44 AC 175 ms
54,844 KB
testcase_45 AC 120 ms
52,892 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 = 0; dy < H; dy++){
			for(int dx = 0; 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 - dy; y++){
					for(int x = 0; x < W - dx; x++){
						final int nx = x + dx;
						final int ny = y + dy;
						
						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