Submission #1077077


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
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 232 Byte
Status
Exec Time 227 ms
Memory 26128 KB

Compile Error

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

Judge Result

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 2040 KB
0_01.txt 13 ms 2044 KB
0_02.txt 13 ms 2044 KB
1_00.txt 13 ms 2044 KB
1_01.txt 13 ms 2044 KB
1_02.txt 144 ms 26128 KB
1_03.txt 146 ms 25988 KB
1_04.txt 144 ms 26128 KB
1_05.txt 145 ms 26128 KB
1_06.txt 146 ms 26124 KB
1_07.txt 146 ms 26124 KB
1_08.txt 147 ms 26116 KB
1_09.txt 147 ms 26128 KB
1_10.txt 146 ms 26120 KB
1_11.txt 144 ms 26120 KB
1_12.txt 146 ms 25992 KB
1_13.txt 197 ms 21240 KB
1_14.txt 201 ms 21248 KB
1_15.txt 201 ms 21248 KB
1_16.txt 185 ms 23312 KB
1_17.txt 184 ms 23304 KB
1_18.txt 183 ms 23308 KB
1_19.txt 164 ms 18424 KB
1_20.txt 158 ms 18412 KB
1_21.txt 160 ms 18420 KB
1_22.txt 198 ms 20488 KB
1_23.txt 207 ms 22408 KB
1_24.txt 205 ms 22668 KB
1_25.txt 201 ms 22664 KB
1_26.txt 192 ms 21768 KB
1_27.txt 202 ms 22796 KB
1_28.txt 186 ms 18236 KB
1_29.txt 179 ms 18104 KB
1_30.txt 180 ms 18240 KB
1_31.txt 199 ms 20408 KB
1_32.txt 205 ms 23944 KB
1_33.txt 195 ms 21640 KB
1_34.txt 207 ms 23564 KB
1_35.txt 198 ms 19904 KB
1_36.txt 212 ms 20108 KB
1_37.txt 200 ms 19768 KB
1_38.txt 227 ms 22924 KB
1_39.txt 201 ms 21180 KB
1_40.txt 200 ms 21048 KB
1_41.txt 201 ms 21184 KB
1_42.txt 201 ms 21184 KB
1_43.txt 141 ms 24204 KB
1_44.txt 141 ms 24328 KB
1_45.txt 141 ms 24332 KB
1_46.txt 142 ms 24332 KB
1_47.txt 133 ms 24208 KB
1_48.txt 132 ms 24204 KB
1_49.txt 133 ms 24200 KB
1_50.txt 133 ms 24196 KB
1_51.txt 141 ms 25348 KB
1_52.txt 140 ms 25352 KB
1_53.txt 140 ms 25356 KB
1_54.txt 141 ms 25360 KB