結果
問題 |
No.3040 Aoiスコア
|
ユーザー |
|
提出日時 | 2025-02-28 21:56:15 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 59 ms / 1,000 ms |
コード長 | 1,223 bytes |
コンパイル時間 | 5,113 ms |
コンパイル使用メモリ | 335,088 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 20:57:37 |
合計ジャッジ時間 | 6,148 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include<atcoder/all> using mint = atcoder::modint998244353; using ld = long double; #define fi first #define se second #define all(x) x.begin(), x.end() #define rep(i,n) for(int i=0;i<(int)(n);++i) #define chmax(a,b) a=max(a,b) #define chmin(a,b) a=min(a,b) int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,M; cin>>N>>M; string S; cin>>S; vector<vector<int>> G(N); rep(i,M){ int a,b; cin>>a>>b; a--;b--; G[a].push_back(b); G[b].push_back(a); } int hc=0; rep(i,N) if(S[i]=='?') hc++; mint ans=0; vector<mint> p(N+1,1); rep(i,N) p[i+1]=p[i]*26; rep(i,N){ if(S[i]=='o'||S[i]=='?'){ int d=(S[i]=='?'); for(int a: G[i]){ for(int b: G[i]){ if(a==b) continue; if(S[a]=='?'&&S[b]=='?') ans+=p[hc-2-d]; else if(S[a]=='a'&&S[b]=='i') ans+=p[hc-d]; else if(S[a]=='a'&&S[b]=='?') ans+=p[hc-1-d]; else if(S[a]=='?'&&S[b]=='i') ans+=p[hc-1-d]; } } } } cout<<ans.val()<<"\n"; }