Submission #18397451


Source Code Expand

Copy
H,W = gets.split.map(&:to_i)
G = $<.read+?#*W
P = Hash.new{|h,k| h[k] = [] }
i = 0
while i = G.index(/[a-z]+/,i)
$&.chars{|c|
P[c] << i
i += 1
}
end
t,T = 0,[nil]*(~H*~W)
*q = G.index ?S
until q.empty?
q.size.times{
i = q.shift
T[i] and next or T[i] = t
case c = G[i]
when ?G
p t
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
H,W = gets.split.map(&:to_i)
G = $<.read+?#*W

P = Hash.new{|h,k| h[k] = [] }
i = 0
while i = G.index(/[a-z]+/,i)
	$&.chars{|c|
		P[c] << i
		i += 1
	}
end

t,T = 0,[nil]*(~H*~W)
*q = G.index ?S
until q.empty?
	q.size.times{
		i = q.shift
		T[i] and next or T[i] = t
		case c = G[i]
		when ?G
			p t
			exit
		when ?#,"\n"
		else
			q << i+1 unless T[i+1]
			q << i-1 unless T[i-1]
			q << i-~W unless T[i-~W]
			q << i+~W unless T[i+~W]
			q.concat c.select{|j| T[j].nil? } if c = P.delete(c)
		end
	}
	t += 1
end
p~0

Submission Info

Submission Time
Task E - Third Avenue
User ds14050
Language Ruby (2.7.1)
Score 500
Code Size 553 Byte
Status AC
Exec Time 1883 ms
Memory 62924 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 38
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.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, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
hand_01.txt AC 63 ms 14232 KB
random_01.txt AC 58 ms 14276 KB
random_02.txt AC 61 ms 14092 KB
random_03.txt AC 62 ms 14204 KB
random_04.txt AC 59 ms 14232 KB
random_05.txt AC 56 ms 14096 KB
random_06.txt AC 64 ms 14172 KB
random_07.txt AC 59 ms 14376 KB
random_08.txt AC 60 ms 14180 KB
random_09.txt AC 62 ms 13980 KB
random_10.txt AC 58 ms 14172 KB
random_11.txt AC 60 ms 14064 KB
random_12.txt AC 63 ms 14200 KB
random_13.txt AC 61 ms 14080 KB
random_14.txt AC 61 ms 14160 KB
random_15.txt AC 61 ms 14268 KB
random_16.txt AC 83 ms 16556 KB
random_17.txt AC 592 ms 35124 KB
random_18.txt AC 179 ms 25628 KB
random_19.txt AC 73 ms 16120 KB
random_20.txt AC 267 ms 33976 KB
random_21.txt AC 71 ms 14572 KB
random_22.txt AC 81 ms 14832 KB
random_23.txt AC 317 ms 26112 KB
random_24.txt AC 287 ms 31220 KB
random_25.txt AC 164 ms 17056 KB
random_26.txt AC 64 ms 14424 KB
random_27.txt AC 203 ms 28320 KB
random_28.txt AC 74 ms 14824 KB
random_29.txt AC 64 ms 14296 KB
random_30.txt AC 197 ms 26984 KB
random_31.txt AC 1125 ms 54436 KB
random_32.txt AC 1387 ms 62924 KB
random_33.txt AC 1883 ms 53248 KB
random_34.txt AC 1467 ms 53356 KB
sample_01.txt AC 61 ms 14096 KB
sample_02.txt AC 61 ms 14396 KB
sample_03.txt AC 59 ms 13992 KB


2025-04-29 (Tue)
02:15:35 +00:00