結果
問題 | No.1916 Making Palindrome on Gird |
ユーザー | kozy |
提出日時 | 2022-04-29 21:39:51 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 487 bytes |
コンパイル時間 | 989 ms |
コンパイル使用メモリ | 87,176 KB |
実行使用メモリ | 427,956 KB |
最終ジャッジ日時 | 2023-09-11 12:35:01 |
合計ジャッジ時間 | 12,454 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
71,388 KB |
testcase_01 | AC | 74 ms
71,408 KB |
testcase_02 | AC | 114 ms
77,228 KB |
testcase_03 | AC | 75 ms
71,388 KB |
testcase_04 | AC | 77 ms
75,252 KB |
testcase_05 | AC | 78 ms
75,152 KB |
testcase_06 | AC | 78 ms
75,128 KB |
testcase_07 | AC | 79 ms
75,384 KB |
testcase_08 | AC | 80 ms
75,276 KB |
testcase_09 | AC | 78 ms
75,128 KB |
testcase_10 | AC | 74 ms
71,380 KB |
testcase_11 | AC | 79 ms
75,180 KB |
testcase_12 | AC | 77 ms
75,052 KB |
testcase_13 | AC | 96 ms
77,164 KB |
testcase_14 | AC | 104 ms
78,824 KB |
testcase_15 | AC | 1,309 ms
279,244 KB |
testcase_16 | AC | 804 ms
195,284 KB |
testcase_17 | AC | 2,606 ms
324,024 KB |
testcase_18 | TLE | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
mod=10**9+7 def ans(a,b,c,d): if not (0<=a<H and 0<=b<W and 0<=c<H and 0<=d<W): return 0 if (a,b,c,d) in D: return D[(a,b,c,d)] x=0 if L[a][b]!=L[c][d]: return 0 if (a,b)==(c,d): return 1 if (a+1,b)==(c,d) or (a,b+1)==(c,d): return 1 X=(ans(a+1,b,c-1,d)+ans(a,b+1,c,d-1)+ans(a,b+1,c-1,d)+ans(a+1,b,c,d-1))%mod D[(a,b,c,d)]=X return X H,W=map(int,input().split()) L=list() for i in range(H): S=input() L.append(S) D=dict() print(ans(0,0,H-1,W-1))