結果
問題 | No.1916 Making Palindrome on Gird |
ユーザー | siganai |
提出日時 | 2022-05-01 18:05:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,695 bytes |
コンパイル時間 | 314 ms |
コンパイル使用メモリ | 87,052 KB |
実行使用メモリ | 214,004 KB |
最終ジャッジ日時 | 2023-09-13 10:27:57 |
合計ジャッジ時間 | 11,493 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 144 ms
79,048 KB |
testcase_01 | AC | 149 ms
78,972 KB |
testcase_02 | AC | 157 ms
80,568 KB |
testcase_03 | AC | 145 ms
79,048 KB |
testcase_04 | AC | 150 ms
80,056 KB |
testcase_05 | AC | 153 ms
80,144 KB |
testcase_06 | AC | 154 ms
80,496 KB |
testcase_07 | AC | 151 ms
79,960 KB |
testcase_08 | AC | 156 ms
80,048 KB |
testcase_09 | AC | 147 ms
79,068 KB |
testcase_10 | WA | - |
testcase_11 | AC | 152 ms
80,004 KB |
testcase_12 | AC | 145 ms
78,788 KB |
testcase_13 | AC | 279 ms
123,808 KB |
testcase_14 | AC | 247 ms
114,488 KB |
testcase_15 | AC | 322 ms
139,328 KB |
testcase_16 | AC | 266 ms
108,748 KB |
testcase_17 | AC | 409 ms
192,260 KB |
testcase_18 | AC | 453 ms
214,004 KB |
testcase_19 | AC | 466 ms
213,684 KB |
testcase_20 | AC | 453 ms
213,720 KB |
testcase_21 | AC | 455 ms
213,932 KB |
testcase_22 | AC | 453 ms
213,636 KB |
testcase_23 | AC | 280 ms
208,856 KB |
testcase_24 | AC | 277 ms
208,784 KB |
testcase_25 | AC | 280 ms
208,764 KB |
testcase_26 | AC | 281 ms
209,620 KB |
testcase_27 | AC | 279 ms
208,908 KB |
testcase_28 | AC | 476 ms
213,732 KB |
testcase_29 | AC | 475 ms
213,672 KB |
testcase_30 | AC | 469 ms
213,808 KB |
testcase_31 | AC | 474 ms
213,576 KB |
testcase_32 | AC | 474 ms
213,612 KB |
ソースコード
#!/usr/bin/env PyPy3 from collections import Counter, defaultdict, deque import itertools import re import math from functools import reduce import operator import bisect from heapq import * import functools mod=10 ** 9 + 7 import sys input=sys.stdin.readline h,w=map(int,input().split()) s=[input().rstrip() for _ in range(h)] dp = [[[0] * h for _ in range(h)] for _ in range(h + w - 1)] if s[0][0] == s[-1][-1]: dp[0][0][h-1] = 1 ans = 0 for i in range(1,(h+w-1) // 2 + 1): for sh in range(h): sw = i - sh if 0 <= sh < h and 0 <= sw < w: for gh in range(h): gw = h + w - 2 - i - gh if 0 <= gh < h and 0 <= gw < w: if s[sh][sw] == s[gh][gw]: tmp1 = 0 if sh > 0 and gh < h - 1: tmp1 += dp[i-1][sh - 1][gh + 1] if sh > 0 and gw < w - 1: tmp1 += dp[i-1][sh-1][gh] tmp1 %= mod if sw > 0 and gh < h - 1: tmp1 += dp[i-1][sh][gh + 1] tmp1 %= mod if sw > 0 and gw < w - 1: tmp1 += dp[i-1][sh][gh] tmp1 %= mod if gh >= sh and gw >= sw and gh + gw - sh - sw <= 1: ans += tmp1 ans %= mod else: dp[i][sh][gh] = tmp1 print(ans) #print(dp) else: print(0)