Submission #842360


Source Code Expand

# http://abc037.contest.atcoder.jp/submissions/842265 の移植?です
def read_numbers; gets.split.map(&:to_i); end
H, W = read_numbers.map{|i| i+2}
MAP = 
  Array.new(W, 0) +
  (H-2).times.flat_map{ [0] + read_numbers + [0] } +
  Array.new(W, 0)
ANS = Array.new(W*H)
DIRS = [+1, -1, +W, -W]

$ans = 0
def calc(pos)
  ret = 1
  DIRS.each do |d|
    if MAP[pos] < MAP[pos+d]
      plus = ANS[pos+d] || calc(pos+d)
      ret += plus
    end
  end
  ANS[pos] = ret; $ans += ret
  return ret
end

(H-2).times do |y|
  (W-2).times do |x|
    pos = W+1 + y*W+x
    calc(pos) unless ANS[pos]
  end
end

p $ans

Submission Info

Submission Time
Task D - 経路
User yhara
Language Ruby (2.3.3)
Score 0
Code Size 637 Byte
Status TLE
Exec Time 2115 ms
Memory 90336 KB

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 2110 ms 79072 KB
01.txt RE 899 ms 41340 KB
02.txt TLE 2105 ms 33788 KB
03.txt AC 17 ms 1788 KB
04.txt AC 17 ms 1788 KB
05.txt AC 17 ms 1788 KB
06.txt AC 20 ms 1916 KB
07.txt AC 19 ms 1916 KB
08.txt AC 18 ms 1788 KB
09.txt AC 17 ms 1788 KB
10.txt AC 26 ms 2044 KB
11.txt TLE 2105 ms 33916 KB
12.txt TLE 2109 ms 33916 KB
13.txt TLE 2105 ms 33916 KB
14.txt TLE 2105 ms 33916 KB
15.txt TLE 2115 ms 90336 KB
16.txt TLE 2105 ms 33916 KB
17.txt TLE 2109 ms 33916 KB
18.txt TLE 2084 ms 33788 KB
19.txt AC 1946 ms 33788 KB
sample01.txt AC 17 ms 1788 KB
sample02.txt AC 17 ms 1788 KB