Submission #740921


Source Code Expand

def hoge(a,b,h,w,y,z)
  if b[y]&&b[y][z]
    return b[y][z]
  end
  sum = 0
  if z!=w-1 && a[y][z] < a[y][z+1]
    sum+=1
    sum+=hoge(a,b,h,w,y,z+1)
  end
  if z!=0 && a[y][z] < a[y][z-1]
    sum+=1
    sum+=hoge(a,b,h,w,y,z-1)
  end
  if y!=h-1 && a[y][z] < a[y+1][z]
    sum+=1
    sum+=hoge(a,b,h,w,y+1,z)
  end
  if y!=0 && a[y][z] < a[y-1][z]
    sum+=1
    sum+=hoge(a,b,h,w,y-1,z)
  end
  b[y][z]=sum
  return sum
end

h,w=gets.split.map &:to_i;
a=Array.new(h)
b=Array.new(h){Array.new(w,nil)}
h.times{|i| a[i]=gets.split.map &:to_i}
x=h*w;
h.times{|i| w.times{|j|x+=hoge(a,b,h,w,i,j)%(10**7+7)}}
p x

Submission Info

Submission Time
Task D - 経路
User shohohoh
Language Ruby (2.3.3)
Score 0
Code Size 642 Byte
Status TLE
Exec Time 2116 ms
Memory 92156 KiB

Compile Error

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

Judge Result

Set Name sample All
Score / Max Score 0 / 0 0 / 100
Status
AC × 2
AC × 11
TLE × 10
RE × 1
Set Name Test Cases
sample sample01.txt, sample02.txt
All 00.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample01.txt, sample02.txt
Case Name Status Exec Time Memory
00.txt TLE 2113 ms 92156 KiB
01.txt RE 560 ms 20860 KiB
02.txt TLE 2107 ms 19196 KiB
03.txt AC 17 ms 1788 KiB
04.txt AC 17 ms 1788 KiB
05.txt AC 17 ms 1788 KiB
06.txt AC 18 ms 1788 KiB
07.txt AC 19 ms 1788 KiB
08.txt AC 18 ms 1788 KiB
09.txt AC 17 ms 1788 KiB
10.txt AC 24 ms 1916 KiB
11.txt TLE 2108 ms 19964 KiB
12.txt TLE 2104 ms 19964 KiB
13.txt TLE 2104 ms 19836 KiB
14.txt TLE 2104 ms 19836 KiB
15.txt TLE 2116 ms 87420 KiB
16.txt TLE 2104 ms 19836 KiB
17.txt TLE 2108 ms 19964 KiB
18.txt TLE 2104 ms 19196 KiB
19.txt AC 1840 ms 19196 KiB
sample01.txt AC 17 ms 1788 KiB
sample02.txt AC 17 ms 1788 KiB