結果

問題 No.179 塗り分け
ユーザー shinwisteria
提出日時 2017-03-28 21:12:45
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 3,139 ms
コンパイル使用メモリ 77,752 KB
実行使用メモリ 56,544 KB
最終ジャッジ日時 2024-10-03 03:37:09
合計ジャッジ時間 13,508 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 5
other AC * 28 WA * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Nuriwake {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int H = s.nextInt(), W = s.nextInt(),count = 0;;
		int[][][] color = new int[H][W][2];
		for(int i = 0;i < H;i++){
			String str = s.next();
			for(int j = 0;j < W;j++){
				if(str.charAt(j) == '#'){
					color[i][j][0] = 1;         //1は[0]なら黒、[1]なら青候補
					count++;
				}
			}
		}
		s.close();
		if(count%2 == 1&&count == 0){
			System.out.println("NO");
		}else{
			int redc = count / 2;
			for(int x = 0;x < W;x++){
				for(int y = -H+1;y < H;y++){
					int c = 0;
					for(int i = 0;i < H;i++){
						for(int j = 0;j < W-x;j++){
							if(i+y>0 &&i-y>0&&i+y<H&& i-y<H&&color[i][j][0] == 1&&color[i+y][j+x][0] == 1&&color[i+y][j+x][1] == 0&&color[i][j][1] == 0){
								color[i+y][j+x][1] = 1;
								c++;
								//System.out.println(i+"  "+j+"  "+y+"  "+x);
							}
							color[i][j][1] = 0;
						}
					}
					for(int i = 0;i<H;i++){
						for(int j = 0;j < W;j++){
							color[i][j][1] = 0;
						}
					}
					if(c == redc){
						count = 0;
					}
				}
			}
			if(count == 0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}

}
0