結果
問題 |
No.1646 Avoid Palindrome
|
ユーザー |
![]() |
提出日時 | 2021-08-13 21:43:12 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 505 bytes |
コンパイル時間 | 266 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 77,252 KB |
最終ジャッジ日時 | 2024-10-03 18:10:22 |
合計ジャッジ時間 | 67,800 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 WA * 16 TLE * 16 |
ソースコード
MOD = 998244353 n = int(input()) s = [-1 if c == '?' else ord(c) - 97 for c in input()] for i in range(n - 1): if s[i] != -1 and s[i] == s[i + 1]: print(0) exit(0) for i in range(n - 2): if s[i] != -1 and s[i] == s[i + 2]: print(0) exit(0) ans = 1 for i in range(n): if s[i] == -1: t = 26 - min(2, i) for j in range(min(2, n - i - 1)): if s[i + j + 1] != -1: t -= 1 ans *= t ans % MOD print(ans % MOD)