結果
問題 | No.3040 Aoiスコア |
ユーザー |
![]() |
提出日時 | 2025-02-28 21:43:42 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 147 ms / 1,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 1,787 ms |
コンパイル使用メモリ | 200,872 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 20:55:38 |
合計ジャッジ時間 | 3,142 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int N,M; cin>>N>>M; string S; cin>>S; int ans = 0, mod = 998244353; vector<int> I(N+1); I[0] = 1; for(int i=0;i<N;i++) I[i+1] = I[i]*26%mod; 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 ct = 0; for(char c:S) ct += (c == '?'); for(int i=0;i<N;i++)for(int x:G[i])for(int y:G[i])if(x != y){ int now = ct; if(S[i] == '?') now--; else if(S[i] != 'o') continue; if(S[x] == '?') now--; else if(S[x] != 'a') continue; if(S[y] == '?') now--; else if(S[y] != 'i') continue; ans += I[now]; ans %= mod; } cout<<ans<<endl; }