結果
問題 | No.1916 Making Palindrome on Gird |
ユーザー | ああいい |
提出日時 | 2022-04-29 21:44:38 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 783 bytes |
コンパイル時間 | 400 ms |
コンパイル使用メモリ | 87,144 KB |
実行使用メモリ | 269,356 KB |
最終ジャッジ日時 | 2023-09-11 12:41:31 |
合計ジャッジ時間 | 12,554 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 96 ms
76,244 KB |
testcase_01 | AC | 74 ms
71,272 KB |
testcase_02 | AC | 177 ms
79,380 KB |
testcase_03 | WA | - |
testcase_04 | AC | 101 ms
76,228 KB |
testcase_05 | AC | 102 ms
76,172 KB |
testcase_06 | AC | 103 ms
76,128 KB |
testcase_07 | AC | 105 ms
76,272 KB |
testcase_08 | AC | 104 ms
76,320 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 107 ms
77,104 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | AC | 137 ms
78,616 KB |
testcase_15 | WA | - |
testcase_16 | AC | 848 ms
106,068 KB |
testcase_17 | AC | 2,609 ms
259,876 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 | -- | - |
ソースコード
H,W = map(int,input().split()) S = [input() for _ in range(H)] P = 10 ** 9 + 7 import sys if S[0][0] != S[-1][-1]: print(0) exit() from collections import defaultdict d = defaultdict(int) d[(0,0,H - 1,W - 1)] = 1 ans = 0 for _ in range(H + W - 2): nx = defaultdict(int) for h,w,hh,ww in d: if h == hh and w == ww: ans += d[(h,w,hh,ww)] ans %= P continue for i,j in [(1,0),(0,1)]: for k,l in [(-1,0),(0,-1)]: if h + i < H and w + j < W and hh + k >= 0 and ww + l >= 0: if S[h + i][w + j] == S[hh + k][ww + l]: nx[(h + i,w + j,hh + k,ww + l)] += d[(h,w,hh,ww)] nx[(h + i,w + j,hh + k,ww + l)] %= P d = nx print(ans)