結果

問題 No.1646 Avoid Palindrome
ユーザー tassei903tassei903
提出日時 2021-08-13 22:05:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,198 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 66,056 KB
最終ジャッジ日時 2024-04-14 18:03:24
合計ジャッジ時間 3,438 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,576 KB
testcase_01 AC 37 ms
53,348 KB
testcase_02 AC 37 ms
52,492 KB
testcase_03 AC 36 ms
53,364 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 43 ms
61,612 KB
testcase_35 AC 37 ms
52,272 KB
testcase_36 AC 37 ms
53,312 KB
testcase_37 AC 37 ms
53,804 KB
testcase_38 WA -
testcase_39 AC 37 ms
53,508 KB
testcase_40 AC 37 ms
53,852 KB
testcase_41 AC 37 ms
52,192 KB
testcase_42 AC 36 ms
53,060 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
sys.setrecursionlimit(10**7)
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n = ni()
mod = 998244353
s = input()
def f(i):
    if i==n-1:
        return 0
    if i==n-2:
        if s[-1]=="?":
            return 0
        else:
            return 1
    else:
        return 2-s[i+1:i+3].count("?")
if n==1:
    if s=="?":
        print(26)
    else:
        print(1)
else:
    if s[0:2]=="??":
        ans = (26-f(0))*(25-f(1))
    elif s[0]=="?":
        ans = 25-f(0)
    elif s[1]=="?":
        ans = 25-f(1)
    elif s[0]==s[1]:
        ans = 0
    else:
        ans = 1

    for i in range(n-2):
        if s[i+2]!="?":
            if s[i]==s[i+2] or s[i+1]==s[i+2]:
                ans=0
                break
            else:
                pass
        else:
            #print(ans,f(i+2),i+2)
            ans*=24-f(i+2)
            ans%=mod
            #print(ans)
    print(ans)
0