結果

問題 No.179 塗り分け
ユーザー shinwisteriashinwisteria
提出日時 2017-03-28 21:31:33
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,365 bytes
コンパイル時間 3,658 ms
コンパイル使用メモリ 78,080 KB
実行使用メモリ 55,368 KB
最終ジャッジ日時 2024-04-14 06:21:22
合計ジャッジ時間 14,194 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
54,028 KB
testcase_01 AC 132 ms
54,264 KB
testcase_02 AC 133 ms
54,096 KB
testcase_03 AC 135 ms
54,064 KB
testcase_04 AC 134 ms
54,160 KB
testcase_05 AC 136 ms
54,560 KB
testcase_06 AC 156 ms
54,500 KB
testcase_07 AC 146 ms
54,412 KB
testcase_08 AC 201 ms
54,736 KB
testcase_09 AC 192 ms
54,368 KB
testcase_10 AC 267 ms
55,060 KB
testcase_11 AC 261 ms
55,344 KB
testcase_12 AC 254 ms
54,952 KB
testcase_13 AC 135 ms
53,984 KB
testcase_14 AC 136 ms
54,000 KB
testcase_15 AC 133 ms
54,092 KB
testcase_16 AC 134 ms
54,108 KB
testcase_17 AC 135 ms
54,124 KB
testcase_18 AC 267 ms
54,908 KB
testcase_19 AC 250 ms
55,276 KB
testcase_20 AC 140 ms
54,272 KB
testcase_21 AC 141 ms
54,220 KB
testcase_22 AC 252 ms
55,084 KB
testcase_23 AC 258 ms
55,148 KB
testcase_24 AC 179 ms
54,356 KB
testcase_25 AC 213 ms
54,800 KB
testcase_26 WA -
testcase_27 AC 267 ms
55,188 KB
testcase_28 WA -
testcase_29 AC 278 ms
55,108 KB
testcase_30 WA -
testcase_31 AC 274 ms
54,912 KB
testcase_32 AC 342 ms
55,368 KB
testcase_33 AC 285 ms
55,088 KB
testcase_34 WA -
testcase_35 AC 283 ms
55,176 KB
testcase_36 AC 133 ms
54,200 KB
testcase_37 AC 133 ms
54,376 KB
testcase_38 AC 132 ms
54,248 KB
testcase_39 AC 134 ms
54,172 KB
testcase_40 AC 132 ms
54,408 KB
testcase_41 AC 133 ms
54,236 KB
testcase_42 AC 134 ms
53,828 KB
testcase_43 AC 162 ms
54,304 KB
testcase_44 AC 184 ms
54,844 KB
testcase_45 AC 138 ms
54,096 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);
							}else 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 i = 0;i<H;i++){
						for(int j = 0;j < W;j++){
							color[i][j][1] = 0;
						}
					}
					if(cp == redc ||cn == redc){
						count = 0;
					}
				}
			}
			if(count == 0){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}

	}

}
0