結果
| 問題 |
No.1646 Avoid Palindrome
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-09-03 11:16:39 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 501 bytes |
| コンパイル時間 | 438 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 11,008 KB |
| 最終ジャッジ日時 | 2024-12-14 15:03:25 |
| 合計ジャッジ時間 | 6,747 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 9 WA * 31 |
ソースコード
n=int(input())
s=input()
S="Z"+s
for i in range(2,n+1):
if (S[i-1]==S[i] or S[i-2]==S[i]) and S[i]!="?":
print(0)
exit()
S="ZZ"+s+"ZZ"
ans=1
mod=998244353
for i in range(2,n+2):
if S[i].islower():
continue
words=set()
count=0#注目している場所より手前の?の数
for j in range(i-2,i+3):
if S[j].islower():
words.add(j)
elif S[j]=="?" and j<i:
count+=1
ans*=(26-len(words)-count)
ans%=mod
print(ans)