結果
| 問題 | No.1916 Making Palindrome on Gird |
| ユーザー |
回転
|
| 提出日時 | 2026-11-12 13:10:06 |
| 言語 | PyPy3 (8.0.1 + ACL) |
| 結果 |
MLE
不安定
|
| 実行時間 | - |
| コード長 | 969 bytes |
| 記録 | |
| コンパイル時間 | 403 ms |
| コンパイル使用メモリ | 64,556 KB |
| 実行使用メモリ | 643,088 KB |
| 最終ジャッジ日時 | 2026-11-12 13:10:33 |
| 合計ジャッジ時間 | 24,202 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 MLE * 1 -- * 4 |
ソースコード
import pypyjit
pypyjit.set_param("max_unroll_recursion=-1")
import sys
sys.setrecursionlimit(10**7)
from functools import cache
MOD = 10**9+7
H,W = list(map(int,input().split()))
S = [input() for _ in range(H)]
dy = [0,1]
dx = [1,0]
ddy = [0,-1]
ddx = [-1,0]
@cache
def f(y,x,yy):
xx = (H-1 + W-1) - yy - x - y
if(y+x == (H+W-2)//2):return int(abs(y - yy) + abs(x - xx) <= 1)
ret = 0
for i in range(2):
next_y = y + dy[i]
next_x = x + dx[i]
if(next_y < 0 or H <= next_y):continue
if(next_x < 0 or W <= next_x):continue
for j in range(2):
next_yy = yy + ddy[j]
next_xx = xx + ddx[j]
if(next_yy < 0 or H <= next_yy):continue
if(next_xx < 0 or W <= next_xx):continue
if(S[next_y][next_x] != S[next_yy][next_xx]):continue
ret += f(next_y, next_x, next_yy)
ret %= MOD
return ret
print(f(0,0,H-1) if S[0][0] == S[-1][-1] else 0)
回転