結果

問題 No.1740 Alone 'a'
ユーザー ytft
提出日時 2021-12-27 18:58:19
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 747 bytes
コンパイル時間 1,627 ms
コンパイル使用メモリ 168,632 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-01 05:34:21
合計ジャッジ時間 5,408 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other TLE * 1 -- * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,preva=0,mod=998244353;
    long long temp,ans=0;
    string S;
    cin>>N>>S;
    for(int i=0;i<N;++i){
        if(preva){
            temp=max(0,S[i]-'b');
            for(int j=i+1;j<N;++j){
                temp=(temp*25)%mod;
            }
            ans=(ans+temp)%mod;
        }else if(S[i]=='a'){
            preva=1;
        }else{
            temp=1;
            for(int j=i+1;j<N;++j){
                temp=(temp*25)%mod;
            }
            ans=(ans+temp)%mod;
            temp=max(0,S[i]-'b')*(N-1-i);
            for(int j=i+1;j<N-1;++j){
                temp=(temp*25)%mod;
            }
            ans=(ans+temp)%mod;
        }
    }
    cout<<ans<<endl;
}
0