結果

問題 No.179 塗り分け
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-03-31 06:47:35
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 692 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 11,256 KB
実行使用メモリ 15,632 KB
最終ジャッジ日時 2023-09-08 07:58:06
合計ジャッジ時間 29,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,152 KB
testcase_01 AC 84 ms
15,276 KB
testcase_02 AC 82 ms
15,132 KB
testcase_03 AC 90 ms
15,128 KB
testcase_04 AC 83 ms
15,088 KB
testcase_05 AC 400 ms
15,280 KB
testcase_06 AC 75 ms
15,156 KB
testcase_07 TLE -
testcase_08 TLE -
testcase_09 TLE -
testcase_10 AC 78 ms
15,036 KB
testcase_11 AC 80 ms
15,044 KB
testcase_12 AC 2,996 ms
15,520 KB
testcase_13 AC 90 ms
15,284 KB
testcase_14 AC 89 ms
15,224 KB
testcase_15 AC 83 ms
15,080 KB
testcase_16 AC 84 ms
15,172 KB
testcase_17 AC 84 ms
15,304 KB
testcase_18 AC 159 ms
15,336 KB
testcase_19 AC 154 ms
15,388 KB
testcase_20 TLE -
testcase_21 TLE -
testcase_22 TLE -
testcase_23 AC 75 ms
15,276 KB
testcase_24 TLE -
testcase_25 AC 103 ms
15,404 KB
testcase_26 AC 558 ms
15,520 KB
testcase_27 TLE -
testcase_28 AC 248 ms
15,404 KB
testcase_29 TLE -
testcase_30 AC 1,449 ms
15,488 KB
testcase_31 TLE -
testcase_32 AC 972 ms
15,368 KB
testcase_33 TLE -
testcase_34 AC 683 ms
15,580 KB
testcase_35 TLE -
testcase_36 AC 86 ms
15,128 KB
testcase_37 AC 87 ms
15,324 KB
testcase_38 AC 88 ms
15,372 KB
testcase_39 AC 87 ms
15,340 KB
testcase_40 AC 87 ms
15,076 KB
testcase_41 AC 85 ms
15,172 KB
testcase_42 AC 87 ms
15,272 KB
testcase_43 AC 146 ms
15,392 KB
testcase_44 AC 465 ms
15,400 KB
testcase_45 AC 97 ms
15,432 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f(m,dx,dy,h,w)
	i=0
	arr=Array.new(h+2).map{Array.new(w+2,0)}
	c=0
	m.each{|e|
		j=0
		e.chars{|e2|
			if e2=="#"
				arr[i][j]=1
				c+=1
			else
				arr[i][j]=0
			end
			j+=1
		}
		i+=1
	}
	return false if c==0
	h.times{|y|
		w.times{|x|
			y1=y+dy
			x1=x+dx
			if arr[y][x]==1
				return false if x1<0 || x1>=w || y1<0 || y1>=h
				arr[y1][x1]-=1
				c-=2
			end
			next if x1<0 || x1>=w || y1<0 || y1>=h
			return false if arr[y1][x1]<0
		}
	}
	return c==0
end

h,w=gets.split.map{|e| e.to_i}
m=[]
h.times{
	m<<gets.chomp
}



ok=false
h.times{|dy|
	w.times{|dx|
		if dy+dx!=0
			ok=ok||f(m,dx,dy,h,w)
			ok=ok||f(m,-dx,dy,h,w)
		end
	}
}
if ok==true
	puts "YES"
else
	puts "NO"
end
0