結果
| 問題 | No.3040 Aoiスコア |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 21:54:51 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,211 bytes |
| 記録 | |
| コンパイル時間 | 4,967 ms |
| コンパイル使用メモリ | 335,024 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 20:57:26 |
| 合計ジャッジ時間 | 11,023 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 3 |
ソースコード
#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;
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+=mint(26).pow(hc-2-d);
else if(S[a]=='a'&&S[b]=='i') ans+=mint(26).pow(hc-d);
else if(S[a]=='a'&&S[b]=='?') ans+=mint(26).pow(hc-1-d);
else if(S[a]=='?'&&S[b]=='i') ans+=mint(26).pow(hc-1-d);
}
}
}
}
cout<<ans.val()<<"\n";
}