結果

問題 No.179 塗り分け
ユーザー shinwisteriashinwisteria
提出日時 2017-03-28 21:12:45
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,233 bytes
コンパイル時間 3,183 ms
コンパイル使用メモリ 74,852 KB
実行使用メモリ 58,576 KB
最終ジャッジ日時 2023-07-26 16:41:19
合計ジャッジ時間 13,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 113 ms
55,684 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 214 ms
56,200 KB
testcase_09 AC 221 ms
57,704 KB
testcase_10 AC 269 ms
57,336 KB
testcase_11 WA -
testcase_12 AC 262 ms
58,080 KB
testcase_13 AC 120 ms
56,636 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 117 ms
56,120 KB
testcase_17 WA -
testcase_18 AC 218 ms
57,060 KB
testcase_19 AC 289 ms
57,916 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 229 ms
56,776 KB
testcase_23 AC 270 ms
57,916 KB
testcase_24 AC 225 ms
56,372 KB
testcase_25 AC 244 ms
56,516 KB
testcase_26 WA -
testcase_27 AC 222 ms
56,284 KB
testcase_28 WA -
testcase_29 AC 269 ms
58,144 KB
testcase_30 WA -
testcase_31 AC 270 ms
57,672 KB
testcase_32 AC 278 ms
57,676 KB
testcase_33 AC 228 ms
57,472 KB
testcase_34 WA -
testcase_35 AC 229 ms
56,080 KB
testcase_36 AC 114 ms
56,124 KB
testcase_37 AC 116 ms
55,964 KB
testcase_38 AC 118 ms
56,136 KB
testcase_39 AC 114 ms
55,952 KB
testcase_40 AC 117 ms
55,952 KB
testcase_41 AC 117 ms
55,976 KB
testcase_42 AC 117 ms
56,132 KB
testcase_43 AC 150 ms
56,748 KB
testcase_44 AC 176 ms
56,804 KB
testcase_45 AC 118 ms
56,316 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 = -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