結果

問題 No.179 塗り分け
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2015-06-19 16:21:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 268 ms / 3,000 ms
コード長 1,794 bytes
コンパイル時間 2,003 ms
コンパイル使用メモリ 74,780 KB
実行使用メモリ 61,540 KB
最終ジャッジ日時 2023-09-30 20:42:08
合計ジャッジ時間 11,222 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,848 KB
testcase_01 AC 118 ms
55,940 KB
testcase_02 AC 121 ms
55,684 KB
testcase_03 AC 122 ms
55,796 KB
testcase_04 AC 117 ms
55,808 KB
testcase_05 AC 173 ms
58,616 KB
testcase_06 AC 122 ms
56,052 KB
testcase_07 AC 209 ms
59,436 KB
testcase_08 AC 220 ms
59,448 KB
testcase_09 AC 208 ms
59,300 KB
testcase_10 AC 126 ms
55,844 KB
testcase_11 AC 126 ms
55,916 KB
testcase_12 AC 268 ms
60,624 KB
testcase_13 AC 120 ms
56,080 KB
testcase_14 AC 126 ms
55,712 KB
testcase_15 AC 120 ms
55,640 KB
testcase_16 AC 127 ms
55,888 KB
testcase_17 AC 120 ms
55,432 KB
testcase_18 AC 162 ms
57,092 KB
testcase_19 AC 163 ms
57,192 KB
testcase_20 AC 225 ms
60,780 KB
testcase_21 AC 186 ms
59,600 KB
testcase_22 AC 217 ms
60,680 KB
testcase_23 AC 127 ms
55,892 KB
testcase_24 AC 219 ms
59,480 KB
testcase_25 AC 158 ms
56,660 KB
testcase_26 AC 187 ms
59,988 KB
testcase_27 AC 232 ms
60,344 KB
testcase_28 AC 177 ms
61,540 KB
testcase_29 AC 224 ms
60,216 KB
testcase_30 AC 200 ms
60,624 KB
testcase_31 AC 234 ms
60,396 KB
testcase_32 AC 211 ms
60,052 KB
testcase_33 AC 232 ms
60,068 KB
testcase_34 AC 188 ms
59,832 KB
testcase_35 AC 214 ms
60,176 KB
testcase_36 AC 120 ms
55,892 KB
testcase_37 AC 120 ms
55,900 KB
testcase_38 AC 120 ms
55,980 KB
testcase_39 AC 122 ms
55,432 KB
testcase_40 AC 122 ms
55,720 KB
testcase_41 AC 121 ms
56,352 KB
testcase_42 AC 121 ms
56,208 KB
testcase_43 AC 159 ms
57,464 KB
testcase_44 AC 182 ms
60,244 KB
testcase_45 AC 122 ms
56,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	static int h, w;
	static int[][] map;
	static int count;
	
	static void start()
	{
		for(int dy = 0;dy < h;dy++)
			for(int dx = 0;dx < w;dx++)
			{
				if(dx == 0 && dy == 0) continue;
				
				int[][] mapp = new int[h][w];
				int cc = 0;
				for(int y = 0;y < h;y++)
					for(int x= 0;x < w;x++)
						mapp[y][x] = 0;
				
				for(int y = 0;y < (h-dy);y++)
					for(int x = 0;x < (w-dx);x++)
					{
						if(mapp[y][x] == 1) continue;
						if(map[y][x] == 0) continue;
						if(map[y+dy][x+dx] == 0) continue;
						
						mapp[y][x] = 1;
						mapp[y+dy][x+dx] = 1;
						cc += 2;
						if(cc == count)
						{
							System.out.println("YES");
							return;
						}
					}
				
				cc = 0;
				for(int y = 0;y < h;y++)
					for(int x= 0;x < w;x++)
						mapp[y][x] = 0;
				
				for(int y = h-1;y >= dy;y--)
					for(int x = 0;x < (w-dx);x++)
					{
						if(mapp[y][x] == 1) continue;
						if(map[y][x] == 0) continue;
						if(map[y-dy][x+dx] == 0) continue;
						
						mapp[y][x] = 1;
						mapp[y-dy][x+dx] = 1;
						cc += 2;
						if(cc == count)
						{
							System.out.println("YES");
							return;
						}
					}
			}
		
		System.out.println("NO");
	}
	
	public static void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			h = sca.nextInt();
			w = sca.nextInt();
			
			map = new int[h][w];
			count = 0;
			for(int y = 0;y < h;y++)
			{
				String str = sca.next();
				for(int x = 0;x < w;x++)
				{
					if(str.charAt(x) == '#')
					{
						map[y][x] = 1;
						count++;
					}
					else
					{
						map[y][x] = 0;
					}
				}
			}
			
			start();
			break;
		}
	}
}
0