結果
| 問題 | No.3040 Aoiスコア |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-28 22:29:07 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,091 bytes |
| 記録 | |
| コンパイル時間 | 215 ms |
| コンパイル使用メモリ | 82,832 KB |
| 実行使用メモリ | 79,288 KB |
| 最終ジャッジ日時 | 2025-06-20 20:59:07 |
| 合計ジャッジ時間 | 7,011 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 TLE * 1 -- * 2 |
ソースコード
import sys
sys.setrecursionlimit(10**8)
import pypyjit
pypyjit.set_param('max_unroll_recursion=-1')
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-=1
b-=1
connect[a].append(b)
connect[b].append(a)
ans=0
mod=998244353
def DFS(now,deepth,used):
global ans
global visited
if deepth==2:
cnt=1
for _ in range(hate-used):
cnt*=26
cnt%=mod
ans+=cnt
ans%=mod
return 0
for to in connect[now]:
if s[to] == word[deepth+1] or s[to]=="?":
if not visited[to]:
visited[to]=True
if s[to]=="?":
DFS(to,deepth+1,used+1)
else:
DFS(to,deepth+1,used)
visited[to]=False
word="aoi"
for start in range(n):
visited=[False]*n
if s[start] in "?a":
visited[start]=True
if s[start]=="?":
DFS(start,0,1)
else:
DFS(start,0,0)
ans%=mod
print(ans)