Submission #1077083


Source Code Expand

Copy
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>'50000000'},'ruby',$0)
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 f(i,c)
	h=(H[i].map{|e|f e,i}.max||0)+1
	(h=0;$r+=1)if h>=K&&c!=1
	h
end
f(1,1)
p $r+(A[0]==1?0:1)

Submission Info

Submission Time
Task D - Teleporter
User leafmoon
Language Ruby (2.3.3)
Score 800
Code Size 269 Byte
Status
Exec Time 676 ms
Memory 225308 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 800 / 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 52 ms 4300 KB
0_01.txt 53 ms 4304 KB
0_02.txt 53 ms 4304 KB
1_00.txt 52 ms 4304 KB
1_01.txt 52 ms 4304 KB
1_02.txt 667 ms 225300 KB
1_03.txt 666 ms 225248 KB
1_04.txt 670 ms 225296 KB
1_05.txt 658 ms 225232 KB
1_06.txt 667 ms 225304 KB
1_07.txt 676 ms 225244 KB
1_08.txt 664 ms 225236 KB
1_09.txt 665 ms 225308 KB
1_10.txt 538 ms 126376 KB
1_11.txt 443 ms 123552 KB
1_12.txt 435 ms 123540 KB
1_13.txt 246 ms 22668 KB
1_14.txt 239 ms 22616 KB
1_15.txt 244 ms 22552 KB
1_16.txt 224 ms 24740 KB
1_17.txt 225 ms 24732 KB
1_18.txt 226 ms 24744 KB
1_19.txt 208 ms 19856 KB
1_20.txt 202 ms 19912 KB
1_21.txt 206 ms 19912 KB
1_22.txt 251 ms 23784 KB
1_23.txt 242 ms 24884 KB
1_24.txt 248 ms 23592 KB
1_25.txt 242 ms 24036 KB
1_26.txt 245 ms 24224 KB
1_27.txt 236 ms 24040 KB
1_28.txt 229 ms 19544 KB
1_29.txt 225 ms 19728 KB
1_30.txt 226 ms 19672 KB
1_31.txt 249 ms 22160 KB
1_32.txt 283 ms 25384 KB
1_33.txt 244 ms 23848 KB
1_34.txt 235 ms 22352 KB
1_35.txt 239 ms 22420 KB
1_36.txt 240 ms 22484 KB
1_37.txt 238 ms 22424 KB
1_38.txt 241 ms 22416 KB
1_39.txt 254 ms 23768 KB
1_40.txt 238 ms 23568 KB
1_41.txt 240 ms 23656 KB
1_42.txt 239 ms 23708 KB
1_43.txt 272 ms 32404 KB
1_44.txt 272 ms 32532 KB
1_45.txt 267 ms 32600 KB
1_46.txt 267 ms 32280 KB
1_47.txt 400 ms 78232 KB
1_48.txt 396 ms 78480 KB
1_49.txt 398 ms 78944 KB
1_50.txt 399 ms 78476 KB
1_51.txt 637 ms 195032 KB
1_52.txt 639 ms 194840 KB
1_53.txt 625 ms 195028 KB
1_54.txt 640 ms 195552 KB