結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
53,676 KB
testcase_01 AC 115 ms
53,172 KB
testcase_02 AC 115 ms
52,980 KB
testcase_03 AC 130 ms
54,016 KB
testcase_04 AC 131 ms
53,832 KB
testcase_05 AC 170 ms
54,408 KB
testcase_06 AC 134 ms
54,080 KB
testcase_07 WA -
testcase_08 AC 190 ms
54,528 KB
testcase_09 WA -
testcase_10 AC 141 ms
53,692 KB
testcase_11 AC 141 ms
53,840 KB
testcase_12 AC 215 ms
54,824 KB
testcase_13 AC 135 ms
53,928 KB
testcase_14 AC 137 ms
54,004 KB
testcase_15 AC 133 ms
53,812 KB
testcase_16 AC 130 ms
53,900 KB
testcase_17 AC 131 ms
54,152 KB
testcase_18 AC 169 ms
54,408 KB
testcase_19 AC 166 ms
54,372 KB
testcase_20 AC 190 ms
54,732 KB
testcase_21 AC 207 ms
54,736 KB
testcase_22 AC 180 ms
54,268 KB
testcase_23 AC 140 ms
54,404 KB
testcase_24 AC 181 ms
54,544 KB
testcase_25 AC 165 ms
54,288 KB
testcase_26 WA -
testcase_27 AC 230 ms
54,936 KB
testcase_28 WA -
testcase_29 AC 227 ms
54,560 KB
testcase_30 WA -
testcase_31 AC 236 ms
54,812 KB
testcase_32 AC 181 ms
54,352 KB
testcase_33 AC 235 ms
54,816 KB
testcase_34 WA -
testcase_35 AC 229 ms
54,536 KB
testcase_36 AC 130 ms
54,096 KB
testcase_37 AC 116 ms
52,472 KB
testcase_38 AC 131 ms
53,992 KB
testcase_39 AC 131 ms
53,752 KB
testcase_40 AC 133 ms
54,104 KB
testcase_41 AC 134 ms
53,732 KB
testcase_42 AC 134 ms
54,068 KB
testcase_43 AC 162 ms
54,204 KB
testcase_44 AC 187 ms
54,788 KB
testcase_45 AC 135 ms
53,796 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