AtCoder Beginner Contest 037

Submission #842360

Source codeソースコード

# 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

Task問題 D - 経路
User nameユーザ名 Yutaka Hara
Created time投稿日時
Language言語 Ruby (2.3.3)
Status状態 TLE
Score得点 0
Source lengthソースコード長 637 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample01.txt,sample02.txt
All 0 / 100 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

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00.txt TLE
01.txt RE
02.txt TLE
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
12.txt TLE
13.txt TLE
14.txt TLE
15.txt TLE
16.txt TLE
17.txt TLE
18.txt TLE
19.txt AC 1946 ms 33788 KB
sample01.txt AC 17 ms 1788 KB
sample02.txt AC 17 ms 1788 KB