結果

問題 No.1646 Avoid Palindrome
ユーザー yunix91201367yunix91201367
提出日時 2021-08-13 21:42:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,632 bytes
コンパイル時間 2,773 ms
コンパイル使用メモリ 201,644 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 17:19:34
合計ジャッジ時間 3,989 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,940 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 3 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/math>
using namespace std;
using namespace atcoder;
#define int long long
using vec_int = vector<int>;
using vec_ii = vector<vec_int>;
using vec_iii = vector<vec_ii>;
using vec_iiii = vector<vec_iii>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

void cout_line(vector<int> &a){
    for(int i=0;i<a.size();i++){
        if(i<a.size()-1){
            cout<<a.at(i)<<" ";
        }else{
            cout<<a.at(i)<<endl;
        }
    }
}

int charToInt(char c){
    char zero_num = '0';
    return (int)c - (int)zero_num;
}

signed main(){
    int N; cin>>N;
    string S; cin>>S;
    int MOD = 998244353;

    rep(i, S.size()-1){
        if(S.at(i)!='?'&&S.at(i+1)!='?'){
            if(S.at(i)==S.at(i+1)){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    rep(i, S.size()-2){
        if(S.at(i)!='?'&&S.at(i+2)!='?'){
            if(S.at(i)==S.at(i+2)){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    int ans = 1;
    rep(i, S.size()){
        if(S.at(i)=='?'){
            int minus = 0;
            if(i>0)minus++;
            if(i>1)minus++;
            if(N-i>1){
                if(S.at(i+1)!='?'){
                    minus++;
                }
            }
            if(N-i>2){
                if(S.at(i+2)!='?'){
                    minus++;
                }
            }
            ans *= 26-minus;
            ans %= MOD;


        }
    }
    cout<<ans<<endl;



    return 0;
}
0