Submission #51311820


Source Code Expand

Copy
(N,H,W),*AB = $<.map{|ln| ln.split.map(&:to_i) }
HW = [*0...H].product([*0...W])
F = lambda{|g,((a,b),*abs)|
i,j = HW.find{|i,j| ! g[i][j] }
next true unless i
next unless a
g2 = g.map(&:dup)
next a.times.all?{|di|
b.times.all?{|dj|
g[i+di][j+dj] = true if i+di<H && j+dj<W && ! g[i+di][j+dj]
}
}&&F[g,abs]||b.times.all?{|di|
a.times.all?{|dj|
g2[i+di][j+dj] = true if i+di<H && j+dj<W && ! g2[i+di][j+dj]
}
}&&F[g2,abs]
}
puts(AB.permutation.any?{|abs|
F[Array.new(H){[nil]*W},abs]
}?'Yes':'No')
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
(N,H,W),*AB = $<.map{|ln| ln.split.map(&:to_i) }
HW = [*0...H].product([*0...W])
F = lambda{|g,((a,b),*abs)|
	i,j = HW.find{|i,j| ! g[i][j] }
	next true unless i
	next unless a
	g2 = g.map(&:dup)
	next a.times.all?{|di|
		b.times.all?{|dj|
			g[i+di][j+dj] = true if i+di<H && j+dj<W && ! g[i+di][j+dj]
		}
	}&&F[g,abs]||b.times.all?{|di|
		a.times.all?{|dj|
			g2[i+di][j+dj] = true if i+di<H && j+dj<W && ! g2[i+di][j+dj]
		}
	}&&F[g2,abs]
}
puts(AB.permutation.any?{|abs|
	F[Array.new(H){[nil]*W},abs]
}?'Yes':'No')

Submission Info

Submission Time
Task D - Tiling
User ds14050
Language Ruby (ruby 3.2.2)
Score 0
Code Size 539 Byte
Status TLE
Exec Time 2025 ms
Memory 17740 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 450
Status
AC × 4
AC × 81
TLE × 1
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt, example_03.txt
All example_00.txt, example_01.txt, example_02.txt, example_03.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, hand_27.txt, hand_28.txt, hand_29.txt, hand_30.txt, hand_31.txt, hand_32.txt, hand_33.txt, hand_34.txt, hand_35.txt, random2_00.txt, random2_01.txt, random2_02.txt, random2_03.txt, random2_04.txt, random2_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt
Case Name Status Exec Time Memory
example_00.txt AC 45 ms 17460 KB
example_01.txt AC 42 ms 17220 KB
example_02.txt AC 42 ms 17216 KB
example_03.txt AC 45 ms 17560 KB
hand_00.txt AC 52 ms 17480 KB
hand_01.txt AC 42 ms 17524 KB
hand_02.txt AC 59 ms 17580 KB
hand_03.txt AC 42 ms 17200 KB
hand_04.txt AC 41 ms 17060 KB
hand_05.txt TLE 2025 ms 17416 KB
hand_06.txt AC 43 ms 17448 KB
hand_07.txt AC 125 ms 17488 KB
hand_08.txt AC 49 ms 17332 KB
hand_09.txt AC 42 ms 17460 KB
hand_10.txt AC 46 ms 17500 KB
hand_11.txt AC 67 ms 17384 KB
hand_12.txt AC 49 ms 17584 KB
hand_13.txt AC 67 ms 17604 KB
hand_14.txt AC 80 ms 17388 KB
hand_15.txt AC 42 ms 17152 KB
hand_16.txt AC 614 ms 17476 KB
hand_17.txt AC 42 ms 17560 KB
hand_18.txt AC 470 ms 17352 KB
hand_19.txt AC 43 ms 17584 KB
hand_20.txt AC 409 ms 17740 KB
hand_21.txt AC 44 ms 17484 KB
hand_22.txt AC 86 ms 17556 KB
hand_23.txt AC 128 ms 17512 KB
hand_24.txt AC 167 ms 17496 KB
hand_25.txt AC 43 ms 17496 KB
hand_26.txt AC 868 ms 17684 KB
hand_27.txt AC 43 ms 17436 KB
hand_28.txt AC 873 ms 17732 KB
hand_29.txt AC 183 ms 17384 KB
hand_30.txt AC 1037 ms 17724 KB
hand_31.txt AC 1029 ms 17476 KB
hand_32.txt AC 146 ms 17484 KB
hand_33.txt AC 272 ms 17384 KB
hand_34.txt AC 208 ms 17708 KB
hand_35.txt AC 192 ms 17612 KB
random2_00.txt AC 42 ms 17168 KB
random2_01.txt AC 42 ms 17040 KB
random2_02.txt AC 42 ms 17308 KB
random2_03.txt AC 45 ms 17384 KB
random2_04.txt AC 42 ms 17212 KB
random2_05.txt AC 44 ms 17332 KB
random_00.txt AC 42 ms 17208 KB
random_01.txt AC 42 ms 17040 KB
random_02.txt AC 42 ms 17084 KB
random_03.txt AC 43 ms 17552 KB
random_04.txt AC 41 ms 17216 KB
random_05.txt AC 47 ms 17380 KB
random_06.txt AC 42 ms 17324 KB
random_07.txt AC 42 ms 17396 KB
random_08.txt AC 50 ms 17464 KB
random_09.txt AC 43 ms 17440 KB
random_10.txt AC 41 ms 17156 KB
random_11.txt AC 44 ms 17548 KB
random_12.txt AC 41 ms 17196 KB
random_13.txt AC 110 ms 17580 KB
random_14.txt AC 449 ms 17540 KB
random_15.txt AC 44 ms 17448 KB
random_16.txt AC 42 ms 16784 KB
random_17.txt AC 41 ms 17156 KB
random_18.txt AC 42 ms 17576 KB
random_19.txt AC 49 ms 17524 KB
random_20.txt AC 221 ms 17576 KB
random_21.txt AC 46 ms 17428 KB
random_22.txt AC 41 ms 17108 KB
random_23.txt AC 51 ms 17396 KB
random_24.txt AC 43 ms 17468 KB
random_25.txt AC 46 ms 17612 KB
random_26.txt AC 42 ms 17328 KB
random_27.txt AC 55 ms 17432 KB
random_28.txt AC 66 ms 17524 KB
random_29.txt AC 604 ms 17384 KB
random_30.txt AC 46 ms 17416 KB
random_31.txt AC 42 ms 17428 KB
random_32.txt AC 47 ms 17508 KB
random_33.txt AC 48 ms 17196 KB
random_34.txt AC 82 ms 17484 KB
random_35.txt AC 44 ms 17564 KB


2025-04-15 (Tue)
09:57:43 +00:00