結果
問題 |
No.3040 Aoiスコア
|
ユーザー |
|
提出日時 | 2025-02-28 22:49:26 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 677 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 82,600 KB |
実行使用メモリ | 79,624 KB |
最終ジャッジ日時 | 2025-06-20 20:59:48 |
合計ジャッジ時間 | 8,493 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 TLE * 3 -- * 2 |
ソースコード
from collections import deque N,M=map(int,input().split()) S=input() C="aoi" Qcnt=S.count("?") Q=[] for i in range(N): if S[i]=="a" or S[i]=="?":Q.append((i,)) G=[[] for _ in range(N)] for _ in range(M): A,B=map(int,input().split()) A-=1;B-=1 G[A].append(B) G[B].append(A) Q=deque(Q) ans=0 while Q: path=Q.popleft() for nxt in G[path[-1]]: if nxt in set(path):continue if S[nxt]==C[len(path)] or S[nxt]=="?": if len(path)==2: cnt=0 for i in path+(nxt,): if S[i]=="?":cnt+=1 ans+=26**(Qcnt-cnt) else:Q.append(path+(nxt,)) print(ans%998244353)