結果

問題 No.1646 Avoid Palindrome
ユーザー umaruuuunumaruuuun
提出日時 2021-09-03 11:16:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 501 bytes
コンパイル時間 102 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 8,512 KB
最終ジャッジ日時 2023-08-21 05:51:28
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 17 ms
7,796 KB
testcase_02 AC 17 ms
8,112 KB
testcase_03 AC 17 ms
7,724 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 152 ms
8,304 KB
testcase_35 AC 16 ms
7,720 KB
testcase_36 AC 15 ms
7,964 KB
testcase_37 AC 16 ms
7,800 KB
testcase_38 AC 15 ms
7,932 KB
testcase_39 AC 15 ms
8,096 KB
testcase_40 AC 15 ms
7,880 KB
testcase_41 AC 15 ms
8,224 KB
testcase_42 AC 16 ms
7,804 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0