結果
| 問題 |
No.3040 Aoiスコア
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-01 20:19:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 548 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 82,920 KB |
| 実行使用メモリ | 78,428 KB |
| 最終ジャッジ日時 | 2025-06-20 21:02:56 |
| 合計ジャッジ時間 | 2,878 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 11 WA * 15 |
ソースコード
n,m=map(int,input().split())
s=input()
ab=[[*map(int,input().split())]for _ in range(m)]
M=998244353
g=[[]for _ in range(n)]
for a,b in ab:
g[a-1]+=b-1,
g[b-1]+=a-1,
hs=s.count('?')
ans=0
for p in range(n):
a=i=h=0
for v in g[p]:
a+=s[v]=='a'
i+=s[v]=='i'
h+=s[v]=='?'
p0=pow(26,hs,M)
p1=pow(26,hs-1,M)if hs else 0
p2=pow(26,hs-2,M)if hs>1 else 0
p3=pow(26,hs-3,M)if hs>2 else 0
if s[p]=='o':
ans+=a*i*p0+(h>0)*(a*p1+i*p1)+(h>1)*p2*2
if s[p]=='?':
ans+=a*i*p1+(h>0)*(a*p2+i*p2)+(h>1)*p3*2
ans%=M
print(ans)