Submission #1077075


Source Code Expand

Copy
#!/usr/bin/ruby
N,K,*A=`dd`.split.map &:to_i
H=Hash.new{|h,k|h[k]=[]}
(2..N).each{|i|H[A[i-1]]<<i}
$r=0
def dfs(i,c)
	h=(H[i].map{|e|dfs(e,i)}.max||0)+1
	if h>=K&&c!=1
		h=0;$r+=1
	end
	h
end
p dfs(1,1)
p $r+(A[0]==1?0:1)

Submission Info

Submission Time
Task D - Teleporter
User leafmoon
Language Ruby (2.3.3)
Score 0
Code Size 234 Byte
Status
Exec Time 221 ms
Memory 26128 KB

Compile Error

./Main.rb:2: warning: `&' interpreted as argument prefix

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_00.txt, 0_01.txt, 0_02.txt
All 0 / 800 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt, 1_50.txt, 1_51.txt, 1_52.txt, 1_53.txt, 1_54.txt
Case Name Status Exec Time Memory
0_00.txt 13 ms 1912 KB
0_01.txt 12 ms 2044 KB
0_02.txt 12 ms 2044 KB
1_00.txt 12 ms 2044 KB
1_01.txt 12 ms 2044 KB
1_02.txt
1_03.txt
1_04.txt
1_05.txt
1_06.txt
1_07.txt
1_08.txt
1_09.txt
1_10.txt
1_11.txt
1_12.txt
1_13.txt 209 ms 21376 KB
1_14.txt 197 ms 21240 KB
1_15.txt 195 ms 21244 KB
1_16.txt 185 ms 23304 KB
1_17.txt 184 ms 23184 KB
1_18.txt 181 ms 23308 KB
1_19.txt 164 ms 18416 KB
1_20.txt 160 ms 18424 KB
1_21.txt 161 ms 18412 KB
1_22.txt 203 ms 22156 KB
1_23.txt 200 ms 19856 KB
1_24.txt 209 ms 22668 KB
1_25.txt 199 ms 22280 KB
1_26.txt 193 ms 21900 KB
1_27.txt 199 ms 22288 KB
1_28.txt 183 ms 18108 KB
1_29.txt 181 ms 18236 KB
1_30.txt 179 ms 18240 KB
1_31.txt 208 ms 23948 KB
1_32.txt 199 ms 22664 KB
1_33.txt 202 ms 23436 KB
1_34.txt 204 ms 23948 KB
1_35.txt 204 ms 19640 KB
1_36.txt 208 ms 19852 KB
1_37.txt 209 ms 20108 KB
1_38.txt 221 ms 22796 KB
1_39.txt 203 ms 21176 KB
1_40.txt 198 ms 21056 KB
1_41.txt 199 ms 21180 KB
1_42.txt 201 ms 21180 KB
1_43.txt
1_44.txt
1_45.txt
1_46.txt
1_47.txt
1_48.txt
1_49.txt
1_50.txt
1_51.txt
1_52.txt
1_53.txt
1_54.txt