結果

問題 No.179 塗り分け
ユーザー 37zigen37zigen
提出日時 2020-02-19 14:33:31
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 1,472 bytes
コンパイル時間 2,306 ms
コンパイル使用メモリ 78,476 KB
実行使用メモリ 46,276 KB
最終ジャッジ日時 2024-04-16 21:09:43
合計ジャッジ時間 11,351 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 130 ms
41,340 KB
testcase_02 RE -
testcase_03 AC 129 ms
41,296 KB
testcase_04 RE -
testcase_05 AC 187 ms
44,952 KB
testcase_06 RE -
testcase_07 AC 136 ms
41,456 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 243 ms
45,756 KB
testcase_13 AC 131 ms
41,308 KB
testcase_14 AC 133 ms
41,580 KB
testcase_15 AC 130 ms
41,140 KB
testcase_16 RE -
testcase_17 AC 117 ms
39,872 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 222 ms
45,740 KB
testcase_21 AC 208 ms
45,536 KB
testcase_22 AC 196 ms
44,956 KB
testcase_23 RE -
testcase_24 AC 197 ms
44,892 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 242 ms
45,364 KB
testcase_28 RE -
testcase_29 AC 250 ms
45,056 KB
testcase_30 RE -
testcase_31 AC 264 ms
45,156 KB
testcase_32 RE -
testcase_33 AC 244 ms
45,128 KB
testcase_34 RE -
testcase_35 AC 274 ms
45,324 KB
testcase_36 AC 132 ms
41,100 KB
testcase_37 AC 130 ms
41,416 KB
testcase_38 AC 131 ms
41,472 KB
testcase_39 AC 129 ms
41,448 KB
testcase_40 AC 130 ms
41,392 KB
testcase_41 AC 129 ms
41,192 KB
testcase_42 AC 132 ms
41,064 KB
testcase_43 AC 157 ms
42,408 KB
testcase_44 AC 178 ms
45,132 KB
testcase_45 AC 121 ms
40,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void solve(int H,int W,char[][] m) {
		for(int dh=0;dh<H;++dh) {
			for(int dw=0;dw<W;++dw) {
				if(dh==0&&dw==0)continue;
				boolean flag=true;
				int[][] rec=new int[H][W];
				for(int h=0;h<H;++h) {
					for(int w=0;w<W;++w) {
						if(m[h][w]=='.')continue;
						if(rec[h][w]!=0)continue;
						int nh=h+dh;
						int nw=w+dw;
						if(nh>=H||nw>=W) {
							flag=false;
							continue;
						}
						if(rec[nh][nw]==2) {
							flag=false;
							continue;
						}
						flag&=m[nh][nw]=='#';
						rec[h][w]=1;
						rec[nh][nw]=2;
					}
				}
				if(flag) {
					System.out.println("YES");
					System.exit(-1);
				}
			}
		}
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		char[][] m=new char[H][W];
		boolean all=true;
		for(int i=0;i<H;++i) {
			m[i]=sc.next().toCharArray();
			for(int j=0;j<m[i].length;++j)all&=m[i][j]=='.';
		}
		if(all) {
			System.out.println("NO");
			return;
		}
		solve(H,W,m);
		{
			for(int h=0;h<H;++h) {
				int s=0;
				int t=W-1;
				while(s<t) {
					m[h][s]^=m[h][t];
					m[h][t]^=m[h][s];
					m[h][s]^=m[h][t];
					++s;--t;
				}
			}
		}
		solve(H,W,m);
		System.out.println("NO");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0