結果

問題 No.179 塗り分け
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-21 13:37:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 254 ms / 3,000 ms
コード長 2,192 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 74,444 KB
実行使用メモリ 57,120 KB
最終ジャッジ日時 2023-09-30 20:40:43
合計ジャッジ時間 11,172 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,748 KB
testcase_01 AC 121 ms
56,216 KB
testcase_02 AC 120 ms
55,840 KB
testcase_03 AC 120 ms
55,660 KB
testcase_04 AC 121 ms
55,752 KB
testcase_05 AC 170 ms
56,888 KB
testcase_06 AC 125 ms
55,612 KB
testcase_07 AC 127 ms
55,940 KB
testcase_08 AC 205 ms
56,592 KB
testcase_09 AC 208 ms
57,120 KB
testcase_10 AC 156 ms
56,588 KB
testcase_11 AC 132 ms
55,820 KB
testcase_12 AC 184 ms
56,672 KB
testcase_13 AC 123 ms
56,244 KB
testcase_14 AC 125 ms
55,612 KB
testcase_15 AC 118 ms
56,504 KB
testcase_16 AC 119 ms
56,444 KB
testcase_17 AC 119 ms
55,840 KB
testcase_18 AC 161 ms
56,548 KB
testcase_19 AC 156 ms
56,260 KB
testcase_20 AC 196 ms
56,836 KB
testcase_21 AC 211 ms
56,668 KB
testcase_22 AC 181 ms
56,984 KB
testcase_23 AC 161 ms
56,628 KB
testcase_24 AC 177 ms
56,352 KB
testcase_25 AC 158 ms
55,920 KB
testcase_26 AC 162 ms
56,648 KB
testcase_27 AC 251 ms
57,004 KB
testcase_28 AC 164 ms
56,488 KB
testcase_29 AC 254 ms
56,980 KB
testcase_30 AC 219 ms
56,668 KB
testcase_31 AC 223 ms
56,672 KB
testcase_32 AC 221 ms
56,296 KB
testcase_33 AC 223 ms
56,240 KB
testcase_34 AC 188 ms
56,424 KB
testcase_35 AC 238 ms
56,648 KB
testcase_36 AC 119 ms
56,364 KB
testcase_37 AC 119 ms
55,904 KB
testcase_38 AC 120 ms
55,860 KB
testcase_39 AC 119 ms
56,184 KB
testcase_40 AC 119 ms
55,908 KB
testcase_41 AC 120 ms
56,080 KB
testcase_42 AC 119 ms
56,204 KB
testcase_43 AC 157 ms
56,136 KB
testcase_44 AC 184 ms
56,272 KB
testcase_45 AC 123 ms
56,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        int h = koko.nextInt();
        int w = koko.nextInt();
        boolean [][] moto = new boolean[h][w];
        boolean[][] color = new boolean[h][w];
        String[] s = new String[h];
        int count =0;
        for(int i=0; i<h; i++){
            s[i] = koko.next();
            char[] ss = s[i].toCharArray();
            for(int j=0; j<w; j++){
                if(ss[j]=='.'){
                    moto[i][j]=true;
                    color[i][j]=true;
                    count++;
                }
            }
        }
        
        boolean bflag = false;
loop2:  for(int i=0; i<h; i++){//ぬり平行移動(たて
            if(count==h*w){
                break;
            }
            for(int j=-w+1; j<w; j++){//ぬり平行移動(よこ
                if(i!=0||j!=0){
                    for(int a=0; a<h; a++){
                        for(int b=0; b<w; b++){
                            color[a][b]=moto[a][b];
                        }
                    }
                    for(int k=0; k+i<h; k++){
                        for(int l=Math.max(0, -j); l<Math.min(w,w-j); l++){
                            if(!color[k][l]&&!color[k+i][l+j]){
                                color[k][l]=true;
                                color[k+i][l+j]=true;
                            }
                        }
                    }
                    boolean flag = false;
                    for(int m=0; m<h; m++){
                        for(int n=0; n<w; n++){
                            if(!color[m][n]){
                                flag = true;
                                break;
                            }
                        }
                    }
                    if(!flag){
                        System.out.println("YES");
                        bflag = true;
                        break loop2;
                    }
                    
                }
            }
        }
        if(!bflag){
            System.out.println("NO");
        }
    }
}
        
        
0