結果

問題 No.179 塗り分け
ユーザー shinwisteriashinwisteria
提出日時 2017-03-28 21:40:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,572 bytes
コンパイル時間 3,838 ms
コンパイル使用メモリ 77,572 KB
実行使用メモリ 56,052 KB
最終ジャッジ日時 2024-04-14 06:22:19
合計ジャッジ時間 23,395 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
54,064 KB
testcase_01 AC 137 ms
54,200 KB
testcase_02 AC 138 ms
54,252 KB
testcase_03 WA -
testcase_04 AC 136 ms
54,104 KB
testcase_05 AC 139 ms
54,416 KB
testcase_06 AC 162 ms
54,260 KB
testcase_07 AC 143 ms
53,960 KB
testcase_08 AC 1,265 ms
55,596 KB
testcase_09 AC 1,147 ms
55,616 KB
testcase_10 AC 228 ms
55,916 KB
testcase_11 AC 219 ms
55,836 KB
testcase_12 AC 1,124 ms
55,868 KB
testcase_13 AC 133 ms
54,160 KB
testcase_14 WA -
testcase_15 AC 132 ms
54,076 KB
testcase_16 AC 134 ms
54,080 KB
testcase_17 AC 135 ms
53,956 KB
testcase_18 WA -
testcase_19 AC 454 ms
55,916 KB
testcase_20 AC 141 ms
54,204 KB
testcase_21 AC 142 ms
54,048 KB
testcase_22 WA -
testcase_23 AC 208 ms
55,112 KB
testcase_24 AC 1,339 ms
55,780 KB
testcase_25 AC 260 ms
55,652 KB
testcase_26 AC 701 ms
55,564 KB
testcase_27 AC 1,281 ms
55,952 KB
testcase_28 AC 717 ms
55,840 KB
testcase_29 AC 1,281 ms
55,744 KB
testcase_30 AC 338 ms
55,700 KB
testcase_31 WA -
testcase_32 AC 702 ms
55,816 KB
testcase_33 WA -
testcase_34 AC 388 ms
55,864 KB
testcase_35 WA -
testcase_36 AC 133 ms
54,100 KB
testcase_37 AC 133 ms
54,216 KB
testcase_38 AC 134 ms
54,268 KB
testcase_39 AC 136 ms
54,332 KB
testcase_40 AC 133 ms
54,228 KB
testcase_41 AC 135 ms
54,316 KB
testcase_42 AC 133 ms
54,240 KB
testcase_43 AC 201 ms
55,324 KB
testcase_44 AC 295 ms
55,812 KB
testcase_45 AC 158 ms
54,304 KB
権限があれば一括ダウンロードができます

ソースコード

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 = 0;y < H;y++){
					int cp = 0,cn = 0;
					for(int i = 0;i < H;i++){
						for(int j = 0;j < W-x;j++){
							if(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;
								cp++;
								//System.out.println(i+"  "+j+"  "+y+"  "+x);
							}
						}
						for(int r = 0;r<H;r++){
							for(int q = 0;q < W;q++){
								color[r][q][1] = 0;
							}
						}
						for(int j = 0;j <W-x;j++){
							if(i-y>=0&&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;
								cn++;
							}
						}
						for(int r = 0;r<H;r++){
							for(int q = 0;q < W;q++){
								color[r][q][1] = 0;
							}
						}
					}
					if(cp == redc ||cn == redc){
						count = 0;
						break;
					}
				}
				if(count == 0){
					break;
				}
			}
			if(count == 0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}

}
0