結果

問題 No.1646 Avoid Palindrome
ユーザー chocoruskchocorusk
提出日時 2021-08-13 22:15:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,273 ms / 3,000 ms
コード長 1,261 bytes
コンパイル時間 3,874 ms
コンパイル使用メモリ 186,108 KB
実行使用メモリ 146,268 KB
最終ジャッジ日時 2024-04-26 03:06:48
合計ジャッジ時間 56,558 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
146,184 KB
testcase_01 AC 102 ms
146,068 KB
testcase_02 AC 100 ms
145,932 KB
testcase_03 AC 103 ms
145,892 KB
testcase_04 AC 1,166 ms
146,076 KB
testcase_05 AC 1,156 ms
145,988 KB
testcase_06 AC 1,122 ms
146,204 KB
testcase_07 AC 1,157 ms
146,268 KB
testcase_08 AC 1,166 ms
146,112 KB
testcase_09 AC 1,105 ms
146,200 KB
testcase_10 AC 1,139 ms
146,168 KB
testcase_11 AC 1,109 ms
145,996 KB
testcase_12 AC 1,157 ms
145,984 KB
testcase_13 AC 1,168 ms
145,912 KB
testcase_14 AC 2,077 ms
146,232 KB
testcase_15 AC 2,132 ms
146,076 KB
testcase_16 AC 2,075 ms
145,988 KB
testcase_17 AC 2,165 ms
146,192 KB
testcase_18 AC 2,105 ms
146,172 KB
testcase_19 AC 2,100 ms
146,080 KB
testcase_20 AC 2,116 ms
146,156 KB
testcase_21 AC 2,158 ms
146,000 KB
testcase_22 AC 2,081 ms
146,204 KB
testcase_23 AC 2,187 ms
146,040 KB
testcase_24 AC 2,255 ms
145,960 KB
testcase_25 AC 2,259 ms
146,188 KB
testcase_26 AC 2,264 ms
146,076 KB
testcase_27 AC 2,273 ms
146,204 KB
testcase_28 AC 2,261 ms
146,020 KB
testcase_29 AC 579 ms
146,180 KB
testcase_30 AC 573 ms
146,064 KB
testcase_31 AC 565 ms
146,004 KB
testcase_32 AC 572 ms
146,096 KB
testcase_33 AC 571 ms
145,980 KB
testcase_34 AC 2,270 ms
146,084 KB
testcase_35 AC 96 ms
145,920 KB
testcase_36 AC 96 ms
145,860 KB
testcase_37 AC 97 ms
145,888 KB
testcase_38 AC 95 ms
146,020 KB
testcase_39 AC 95 ms
146,096 KB
testcase_40 AC 95 ms
146,072 KB
testcase_41 AC 95 ms
145,932 KB
testcase_42 AC 94 ms
145,968 KB
testcase_43 AC 573 ms
146,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint dp[27][27][50005];
int main()
{
    int n; cin>>n;
    string s; cin>>s;
    dp[26][26][0]=1;
    for(int i=0; i<n; i++){
        for(int j=0; j<26; j++){
            if(s[i]!='?' && s[i]!=(char)('a'+j)) continue;
            for(int k=0; k<27; k++){
                if(k==j) continue;
                for(int l=0; l<27; l++){
                    if(l==j) continue;
                    dp[j][k][i+1]+=dp[k][l][i];
                }
            }
        }
    }
    mint ans=0;
    for(int i=0; i<27; i++){
        for(int j=0; j<27; j++){
            ans+=dp[i][j][n];
        }
    }
    cout<<ans.val()<<endl;
    return 0;
}
0