結果

問題 No.179 塗り分け
ユーザー kou6839kou6839
提出日時 2015-06-21 02:30:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 243 ms / 3,000 ms
コード長 1,381 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 74,452 KB
実行使用メモリ 60,128 KB
最終ジャッジ日時 2023-09-30 20:42:54
合計ジャッジ時間 10,406 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,396 KB
testcase_01 AC 118 ms
56,184 KB
testcase_02 AC 120 ms
55,964 KB
testcase_03 AC 119 ms
53,692 KB
testcase_04 AC 119 ms
55,884 KB
testcase_05 AC 147 ms
58,536 KB
testcase_06 AC 123 ms
55,988 KB
testcase_07 AC 243 ms
60,128 KB
testcase_08 AC 171 ms
58,532 KB
testcase_09 AC 195 ms
59,056 KB
testcase_10 AC 148 ms
55,980 KB
testcase_11 AC 147 ms
56,092 KB
testcase_12 AC 188 ms
58,808 KB
testcase_13 AC 123 ms
56,120 KB
testcase_14 AC 126 ms
55,720 KB
testcase_15 AC 122 ms
55,928 KB
testcase_16 AC 121 ms
55,936 KB
testcase_17 AC 122 ms
56,084 KB
testcase_18 AC 149 ms
56,088 KB
testcase_19 AC 150 ms
56,400 KB
testcase_20 AC 174 ms
58,484 KB
testcase_21 AC 204 ms
59,016 KB
testcase_22 AC 214 ms
58,900 KB
testcase_23 AC 149 ms
56,100 KB
testcase_24 AC 187 ms
58,820 KB
testcase_25 AC 149 ms
56,000 KB
testcase_26 AC 152 ms
58,656 KB
testcase_27 AC 172 ms
58,524 KB
testcase_28 AC 149 ms
58,016 KB
testcase_29 AC 172 ms
58,728 KB
testcase_30 AC 159 ms
58,024 KB
testcase_31 AC 176 ms
57,860 KB
testcase_32 AC 157 ms
58,376 KB
testcase_33 AC 172 ms
58,612 KB
testcase_34 AC 156 ms
58,428 KB
testcase_35 AC 172 ms
58,244 KB
testcase_36 AC 121 ms
55,664 KB
testcase_37 AC 120 ms
55,920 KB
testcase_38 AC 121 ms
55,528 KB
testcase_39 AC 120 ms
55,784 KB
testcase_40 AC 120 ms
56,564 KB
testcase_41 AC 119 ms
56,212 KB
testcase_42 AC 120 ms
55,524 KB
testcase_43 AC 138 ms
55,676 KB
testcase_44 AC 147 ms
58,204 KB
testcase_45 AC 121 ms
55,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main {
	static char[][] copy(char[][] origin){
		char[][] copy = new char[origin.length][origin[0].length];
		
		for(int i=0;i<origin.length;i++){
			for(int j=0;j<origin[0].length;j++){
				copy[i][j]=origin[i][j];
			}
		}
		return copy;
	}
    public static void main(String[] args){
        // TODO 自動生成されたメソッド・スタブ
    	Scanner sc = new Scanner(System.in);
    	
    	int r = sc.nextInt();
    	int c = sc.nextInt();
    	
    	char[][] panel = new char[r][c];
    	for(int i=0;i<r;i++) panel[i]=sc.next().toCharArray();
    	
    	for(int i=0;i<r;i++){
    		t:for(int j=-c+1;j<c;j++){
    			if(i==0 && j==0) continue;
    			char[][] copy = copy(panel);
    			for(int k=0;k<r;k++){
    				for(int l=0;l<c;l++){
    					if(copy[k][l]=='#'){
    						copy[k][l]='r';
    						if(k+i>=0 && k+i<r && l+j>=0 && l+j<c && copy[k+i][l+j]=='#'){
    							copy[k+i][l+j]='b';
    						}else{
    							continue t;
    						}
    					}
    				}
    			}
    			int count=0;
    			for(int k=0;k<r;k++){
    				for(int l=0;l<c;l++){
    					if(copy[k][l]=='.') count++;
    					if(copy[k][l]=='#'){
    						continue t;
    					}
    				}
    			}
    			if(count==r*c) continue t;
    			System.out.println("YES");
    			return;
    		}
    	}
    	System.out.println("NO");
    }
}
0