結果

問題 No.1916 Making Palindrome on Gird
ユーザー googol_S0googol_S0
提出日時 2022-04-29 22:05:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 899 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 210,284 KB
最終ジャッジ日時 2023-09-11 13:17:51
合計ジャッジ時間 20,350 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,300 KB
testcase_01 AC 74 ms
71,136 KB
testcase_02 AC 162 ms
77,660 KB
testcase_03 AC 75 ms
71,064 KB
testcase_04 AC 124 ms
77,544 KB
testcase_05 AC 110 ms
77,200 KB
testcase_06 AC 108 ms
77,560 KB
testcase_07 AC 127 ms
77,500 KB
testcase_08 AC 108 ms
77,360 KB
testcase_09 AC 76 ms
71,328 KB
testcase_10 WA -
testcase_11 AC 121 ms
77,556 KB
testcase_12 AC 102 ms
76,660 KB
testcase_13 AC 574 ms
120,204 KB
testcase_14 AC 387 ms
110,580 KB
testcase_15 AC 693 ms
135,644 KB
testcase_16 AC 467 ms
104,984 KB
testcase_17 AC 1,158 ms
188,708 KB
testcase_18 AC 1,322 ms
210,284 KB
testcase_19 AC 1,312 ms
209,892 KB
testcase_20 AC 1,304 ms
210,124 KB
testcase_21 AC 1,345 ms
210,044 KB
testcase_22 AC 1,332 ms
210,044 KB
testcase_23 AC 75 ms
71,356 KB
testcase_24 AC 74 ms
71,168 KB
testcase_25 AC 76 ms
71,256 KB
testcase_26 AC 76 ms
71,380 KB
testcase_27 AC 76 ms
71,124 KB
testcase_28 AC 1,365 ms
210,076 KB
testcase_29 AC 1,365 ms
210,140 KB
testcase_30 AC 1,388 ms
210,092 KB
testcase_31 AC 1,387 ms
210,140 KB
testcase_32 AC 1,369 ms
210,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=10**9+7
H,W=map(int,input().split())
S=[input() for i in range(H)]
if S[0][0]!=S[-1][-1]:
  print(0)
  exit()
N=H+W-2
DP=[[[0]*H for i in range(H)] for j in range(N+1)]
DP[0][0][H-1]=1
ANS=0
for i in range(N):
  for j in range(H):
    for k in range(H):
      x1,y1=j,i-j
      x2,y2=k,W-1-(i-(H-1-k))
      if y1<0 or y2<0 or y2>=W:
        continue
      if abs(x1-x2)+abs(y1-y2)<=1 and x1<=x2 and y1<=y2:
        ANS=(ANS+DP[i][j][k])%mod
      for l in range(2):
        for m in range(2):
          x3,y3=x1+l,y1+(l^1)
          x4,y4=x2-m,y2-(m^1)
          if H<=x3 or W<=y3 or x4<0 or y4<0:
            continue
          if S[x3][y3]==S[x4][y4]:
            DP[i+1][j+l][k-m]=(DP[i+1][j+l][k-m]+DP[i][j][k])%mod
print(ANS)
0