結果
問題 | No.3040 Aoiスコア |
ユーザー |
|
提出日時 | 2025-02-28 22:07:10 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,031 bytes |
コンパイル時間 | 366 ms |
コンパイル使用メモリ | 82,792 KB |
実行使用メモリ | 79,384 KB |
最終ジャッジ日時 | 2025-02-28 22:07:18 |
合計ジャッジ時間 | 8,130 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 TLE * 1 |
ソースコード
import syssys.setrecursionlimit(10**8)n,m=map(int,input().split())s=list(input())connect=[[] for _ in range(n)]hate=s.count("?")for _ in range(m):a,b=map(int,input().split())a-=1b-=1connect[a].append(b)connect[b].append(a)ans=0mod=998244353def DFS(now,deepth,used):global ansglobal visitedif deepth==2:cnt=1for _ in range(hate-used):cnt*=26cnt%=modans+=cntans%=modreturn 0for to in connect[now]:if s[to] == word[deepth+1] or s[to]=="?":if not visited[to]:visited[to]=Trueif s[to]=="?":DFS(to,deepth+1,used+1)else:DFS(to,deepth+1,used)visited[to]=Falseword="aoi"for start in range(n):visited=[False]*nif s[start] in "?a":visited[start]=Trueif s[start]=="?":DFS(start,0,1)else:DFS(start,0,0)ans%=modprint(ans)