結果
| 問題 | No.3428 Palindromic Path (Easy) |
| コンテスト | |
| ユーザー |
NaH54i
|
| 提出日時 | 2026-01-11 14:02:29 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 99 ms / 2,000 ms |
| + 130µs | |
| コード長 | 717 bytes |
| 記録 | |
| コンパイル時間 | 233 ms |
| コンパイル使用メモリ | 95,728 KB |
| 実行使用メモリ | 84,480 KB |
| 最終ジャッジ日時 | 2026-07-20 05:41:53 |
| 合計ジャッジ時間 | 1,890 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 |
ソースコード
import itertools as it
N = int(input())
C = [input() for _ in range(N)]
P = 998244353
if C[0][0] != C[-1][-1]:
print(0)
quit()
cs = it.combinations(list(range(2 * (N - 1))), N - 1)
ans = 0
for c in cs:
y, x = 0, 0
j = 0
s = []
for i in range(N - 2):
if i == c[j]:
x += 1
j += 1
else:
y += 1
s.append(C[y][x])
if N - 2 == c[j]:
x += 1
j += 1
else:
y += 1
for i in range(N - 2):
if j < N - 1 and i + N - 1 == c[j]:
x += 1
j += 1
else:
y += 1
if C[y][x] != s[-1 - i]:
break
else:
ans = (ans + 1) % P
print(ans)
NaH54i