結果
問題 | No.1740 Alone 'a' |
ユーザー |
![]() |
提出日時 | 2021-11-12 22:20:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 869 bytes |
コンパイル時間 | 3,699 ms |
コンパイル使用メモリ | 229,104 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-25 19:20:56 |
合計ジャッジ時間 | 5,007 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <bits/stdc++.h>using namespace std;#include <atcoder/all>using namespace atcoder;using ll=long long;using Graph=vector<vector<pair<int,ll>>>;#define INF 1000000000#define MOD 998244353#define MAX 200000int main(){int N;string S;cin>>N>>S;vector<ll> pow25(N,1);for(int i=1;i<N;i++){pow25[i]=25*pow25[i-1]%MOD;}bool have_one=false;ll ans=0;for(int i=0;i<N;i++){if(S[i]=='a'){if(have_one){break;}else{have_one=true;continue;}}else{int cnt=S[i]-'a';if(!have_one){ans+=pow25[N-1-i];ans%=MOD;if(i==N-1){break;}ans+=(((ll)cnt-1)*((ll)N-1-i)%MOD)*pow25[N-2-i]%MOD;ans%=MOD;}else{ans+=((ll)cnt-1)*pow25[N-1-i]%MOD;ans%=MOD;}}}cout<<ans<<'\n';}