Submission #1023993
Source Code Expand
if !ENV['RUBY_THREAD_VM_STACK_SIZE'] exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0) end def read_numbers; gets.split.map(&:to_i); end H, W = read_numbers.map{|i| i+2} M = 1000000007 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 ret %= M 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 % M
Submission Info
Submission Time | |
---|---|
Task | D - 経路 |
User | yhara |
Language | Ruby (2.3.3) |
Score | 0 |
Code Size | 717 Byte |
Status | MLE |
Exec Time | 1306 ms |
Memory | 367836 KB |
Judge Result
Set Name | sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 100 | ||||||
Status |
|
|
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 | AC | 1257 ms | 40776 KB |
01.txt | MLE | 1265 ms | 367836 KB |
02.txt | AC | 1204 ms | 36164 KB |
03.txt | AC | 51 ms | 4168 KB |
04.txt | AC | 51 ms | 4164 KB |
05.txt | AC | 51 ms | 4168 KB |
06.txt | AC | 52 ms | 4292 KB |
07.txt | AC | 52 ms | 4296 KB |
08.txt | AC | 51 ms | 4160 KB |
09.txt | AC | 50 ms | 4164 KB |
10.txt | AC | 54 ms | 4428 KB |
11.txt | AC | 1296 ms | 36416 KB |
12.txt | AC | 1257 ms | 36416 KB |
13.txt | AC | 1299 ms | 36424 KB |
14.txt | AC | 1273 ms | 36428 KB |
15.txt | AC | 1246 ms | 40388 KB |
16.txt | AC | 1306 ms | 36428 KB |
17.txt | AC | 1305 ms | 36424 KB |
18.txt | AC | 1156 ms | 36296 KB |
19.txt | AC | 1080 ms | 36296 KB |
sample01.txt | AC | 50 ms | 4164 KB |
sample02.txt | AC | 51 ms | 4300 KB |