結果

問題 No.179 塗り分け
ユーザー Flere0114Flere0114
提出日時 2016-02-24 11:46:21
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,552 bytes
コンパイル時間 3,494 ms
コンパイル使用メモリ 77,904 KB
実行使用メモリ 56,320 KB
最終ジャッジ日時 2024-04-14 06:00:04
合計ジャッジ時間 11,207 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
53,760 KB
testcase_01 AC 129 ms
53,848 KB
testcase_02 AC 131 ms
53,948 KB
testcase_03 WA -
testcase_04 AC 129 ms
53,900 KB
testcase_05 AC 132 ms
53,864 KB
testcase_06 WA -
testcase_07 AC 134 ms
53,972 KB
testcase_08 AC 135 ms
54,128 KB
testcase_09 AC 137 ms
54,112 KB
testcase_10 AC 134 ms
53,836 KB
testcase_11 AC 137 ms
54,112 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 128 ms
54,272 KB
testcase_16 AC 126 ms
54,104 KB
testcase_17 AC 128 ms
54,188 KB
testcase_18 AC 138 ms
54,256 KB
testcase_19 AC 136 ms
54,420 KB
testcase_20 AC 136 ms
53,852 KB
testcase_21 AC 141 ms
54,248 KB
testcase_22 WA -
testcase_23 AC 136 ms
54,288 KB
testcase_24 AC 139 ms
53,992 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 137 ms
54,200 KB
testcase_28 WA -
testcase_29 AC 140 ms
54,168 KB
testcase_30 AC 138 ms
54,316 KB
testcase_31 AC 137 ms
53,988 KB
testcase_32 WA -
testcase_33 AC 140 ms
54,256 KB
testcase_34 WA -
testcase_35 AC 140 ms
53,980 KB
testcase_36 AC 130 ms
53,944 KB
testcase_37 AC 129 ms
54,048 KB
testcase_38 WA -
testcase_39 AC 128 ms
54,100 KB
testcase_40 AC 129 ms
54,280 KB
testcase_41 AC 129 ms
53,964 KB
testcase_42 WA -
testcase_43 AC 133 ms
53,716 KB
testcase_44 AC 136 ms
54,304 KB
testcase_45 AC 131 ms
54,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No179 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        String s;
        int first = 0, trans = 0, diff = 0, count = 0, check = 0;
        boolean[] b = new boolean[h*w];
        for (int i = 0; i < h; i++) {
            s = sc.next();
            for (int j = 0; j < w; j++) {
                if(s.charAt(j) == '#'){
                    b[i*w+j] = true;
                    count++;
                }
            }
        }

        if(count % 2 == 1){
            System.out.println("NO");
            return;
        }
        count /= 2;

        for (int i = 0; i < h * w; i++) {
            if(b[i]){
                first = i;
                break;
            }
        }

        for (int i = first + 1; i < h * w; i++) {
            if(b[i]){
                trans = i;
                diff = trans - first;
                check = 0;
                for (int j = first + 1; j < h * w; j++) {
                    if(b[j] && j != trans){
                        if(j+diff >= h*w || !b[j+diff]){
                            break;
                        }
                        check++;
                    }
                    if(check == count / 2){
                        System.out.println("YES");
                        return;
                    }
                }
            }
        }
        System.out.println("NO");
        return;
    }
}
0