結果
問題 | No.3040 Aoiスコア |
ユーザー |
|
提出日時 | 2025-02-28 21:41:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 75 ms / 1,000 ms |
コード長 | 1,429 bytes |
コンパイル時間 | 1,917 ms |
コンパイル使用メモリ | 201,424 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-28 21:41:13 |
合計ジャッジ時間 | 2,865 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
#include<bits/stdc++.h>using namespace std;using ll=long long;#define all(v) v.begin(),v.end()#define rall(v) v.rbegin(),v.rend()template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}#include<atcoder/modint>using mint=atcoder::modint998244353;void Solve(){int N,M;cin>>N>>M;string S;cin>>S;vector<vector<int>>G(N);for(int i=0;i<M;i++){int a,b;cin>>a>>b;a--;b--;G[a].push_back(b);G[b].push_back(a);}int q=0;for(int i=0;i<N;i++){if(S[i]=='?')q++;}vector<mint>P26(N+1);P26[0]=1;for(int i=1;i<=N;i++)P26[i]=26*P26[i-1];mint ans=0;for(int i=0;i<N;i++){int l=G[i].size();if(S[i]!='?'&&S[i]!='o')continue;for(int j=0;j<l;j++){for(int k=0;k<l;k++){if(j==k)continue;int x=G[i][j],y=G[i][k];if(S[x]!='?'&&S[x]!='a')continue;if(S[y]!='?'&&S[y]!='i')continue;int r=q;if(S[i]=='?')r--;if(S[x]=='?')r--;if(S[y]=='?')r--;ans+=P26[r];}}}cout<<ans.val()<<"\n";}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);Solve();}