Submission #1077088


Source Code Expand

Copy
ENV[Z='RUBY_THREAD_VM_STACK_SIZE']||exec({Z=>'50000000'},'ruby',$0)
def f(i,c)(h=(H[i].map{|e|f e,i}.max||0)+1)>=K&&c!=1&&(h=0;$r+=1);h end
N,K,*A=`dd`.split.map &:to_i
H=Hash.new{|h,k|h[k]=[]}
(2..N).each{|i|H[A[i-1]]<<i}
f($r=1,1)
p $r-(A[0]==1?1:0)

Submission Info

Submission Time
Task D - Teleporter
User leafmoon
Language Ruby (2.3.3)
Score 800
Code Size 257 Byte
Status
Exec Time 681 ms
Memory 225304 KB

Compile Error

./Main.rb:3: 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 53 ms 4308 KB
0_01.txt 52 ms 4300 KB
0_02.txt 52 ms 4296 KB
1_00.txt 52 ms 4296 KB
1_01.txt 53 ms 4296 KB
1_02.txt 660 ms 225304 KB
1_03.txt 681 ms 225300 KB
1_04.txt 669 ms 225252 KB
1_05.txt 671 ms 225304 KB
1_06.txt 665 ms 225240 KB
1_07.txt 656 ms 225292 KB
1_08.txt 660 ms 225300 KB
1_09.txt 665 ms 225236 KB
1_10.txt 440 ms 123544 KB
1_11.txt 436 ms 123540 KB
1_12.txt 438 ms 123548 KB
1_13.txt 257 ms 22740 KB
1_14.txt 240 ms 22628 KB
1_15.txt 233 ms 22676 KB
1_16.txt 223 ms 24740 KB
1_17.txt 223 ms 24744 KB
1_18.txt 224 ms 24680 KB
1_19.txt 205 ms 19932 KB
1_20.txt 199 ms 19928 KB
1_21.txt 201 ms 19920 KB
1_22.txt 249 ms 23716 KB
1_23.txt 243 ms 23668 KB
1_24.txt 243 ms 24228 KB
1_25.txt 243 ms 24160 KB
1_26.txt 251 ms 24868 KB
1_27.txt 237 ms 24168 KB
1_28.txt 224 ms 19540 KB
1_29.txt 223 ms 19668 KB
1_30.txt 221 ms 19604 KB
1_31.txt 256 ms 25244 KB
1_32.txt 246 ms 25248 KB
1_33.txt 244 ms 25324 KB
1_34.txt 244 ms 25380 KB
1_35.txt 236 ms 22480 KB
1_36.txt 233 ms 22424 KB
1_37.txt 242 ms 22480 KB
1_38.txt 233 ms 22428 KB
1_39.txt 247 ms 26548 KB
1_40.txt 241 ms 23580 KB
1_41.txt 239 ms 23692 KB
1_42.txt 238 ms 23708 KB
1_43.txt 267 ms 32408 KB
1_44.txt 285 ms 35376 KB
1_45.txt 271 ms 32656 KB
1_46.txt 278 ms 32408 KB
1_47.txt 397 ms 78228 KB
1_48.txt 397 ms 78356 KB
1_49.txt 397 ms 78944 KB
1_50.txt 395 ms 78472 KB
1_51.txt 631 ms 194964 KB
1_52.txt 626 ms 194832 KB
1_53.txt 633 ms 194952 KB
1_54.txt 637 ms 195480 KB