結果
問題 |
No.1646 Avoid Palindrome
|
ユーザー |
![]() |
提出日時 | 2021-08-13 21:47:17 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 506 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 82,096 KB |
実行使用メモリ | 71,088 KB |
最終ジャッジ日時 | 2024-10-03 18:15:57 |
合計ジャッジ時間 | 3,760 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 9 WA * 31 |
ソースコード
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)