結果
問題 | No.1916 Making Palindrome on Gird |
ユーザー | 👑 SPD_9X2 |
提出日時 | 2022-04-29 22:22:44 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,186 bytes |
コンパイル時間 | 288 ms |
コンパイル使用メモリ | 86,812 KB |
実行使用メモリ | 268,580 KB |
最終ジャッジ日時 | 2023-09-11 13:43:20 |
合計ジャッジ時間 | 15,830 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
75,580 KB |
testcase_01 | AC | 71 ms
71,012 KB |
testcase_02 | AC | 101 ms
77,144 KB |
testcase_03 | AC | 73 ms
71,252 KB |
testcase_04 | AC | 73 ms
71,148 KB |
testcase_05 | AC | 76 ms
74,988 KB |
testcase_06 | AC | 77 ms
75,128 KB |
testcase_07 | AC | 77 ms
74,884 KB |
testcase_08 | AC | 75 ms
75,052 KB |
testcase_09 | AC | 76 ms
74,992 KB |
testcase_10 | AC | 72 ms
71,144 KB |
testcase_11 | AC | 77 ms
75,184 KB |
testcase_12 | AC | 76 ms
75,140 KB |
testcase_13 | AC | 98 ms
78,052 KB |
testcase_14 | AC | 93 ms
76,156 KB |
testcase_15 | AC | 273 ms
83,668 KB |
testcase_16 | AC | 202 ms
79,836 KB |
testcase_17 | AC | 476 ms
97,200 KB |
testcase_18 | AC | 1,566 ms
182,552 KB |
testcase_19 | AC | 1,534 ms
177,068 KB |
testcase_20 | AC | 1,519 ms
179,164 KB |
testcase_21 | AC | 1,529 ms
180,356 KB |
testcase_22 | AC | 1,502 ms
180,084 KB |
testcase_23 | AC | 75 ms
71,360 KB |
testcase_24 | AC | 74 ms
71,112 KB |
testcase_25 | AC | 74 ms
71,332 KB |
testcase_26 | AC | 73 ms
71,260 KB |
testcase_27 | AC | 76 ms
71,392 KB |
testcase_28 | TLE | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
ソースコード
""" https://yukicoder.me/problems/no/1916 dpかな 200*200*200? """ import sys from sys import stdin H,W = map(int,stdin.readline().split()) if H == W == 1: print (1) sys.exit() S = [list(stdin.readline()[:-1]) for i in range(H) ] mod = 10**9+7 q = {} if S[0][0] == S[H-1][W-1]: q[(0,0,H-1,W-1)] = 1 ans = 0 while q: newq = {} for tup in q: x1,y1,x2,y2 = tup cnt = q[tup] for newx1,newy1 in ( (x1+1,y1) , (x1,y1+1) ): for newx2,newy2 in ( (x2-1,y2) , (x2,y2-1) ): fl = (0<=newx1<H and 0<=newy1<W and 0<=newx2<H and 0<=newy2<W) if fl and newx1<=newx2 and newy1<=newy2 and S[newx1][newy1] == S[newx2][newy2]: newtup = (newx1,newy1,newx2,newy2) diff = abs(newx2-newx1) + abs(newy2-newy1) if diff <= 1: ans += cnt ans %= mod elif newtup not in newq: newq[newtup] = cnt else: newq[newtup] += cnt newq[newtup] %= mod q = newq #print (q) print (ans % mod)