結果
| 問題 | No.1677 mæx |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-29 20:53:58 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 202 ms / 2,000 ms |
| コード長 | 923 bytes |
| 記録 | |
| コンパイル時間 | 369 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 128,028 KB |
| 最終ジャッジ日時 | 2026-05-29 20:54:13 |
| 合計ジャッジ時間 | 9,606 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_1 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
ソースコード
import sys
sys.setrecursionlimit(10**5)
def aa(m):
global mod
c=0;d=0
if s[m+1]!="a":
d=1
if s[m+1]!="e":
c=1
m+=4
a=[0,0,0]
if s[m]=="m":
a,m=aa(m)
elif s[m]=="?":
a=[1]*3;m+=1
else:
a[int(s[m])]=1;m+=1
m+=1
b=[0,0,0]
if s[m]=="m":
b,m=aa(m)
elif s[m]=="?":
b=[1]*3;m+=1
else:
b[int(s[m])]=1;m+=1
m+=1
res=[0]*3
if c:
for i in range(3):
for j in range(3):
res[max(i,j)]+=a[i]*b[j];res[max(i,j)]%=mod
if d:
for i in range(3):
for j in range(3):
for l in range(3):
if i!=l and j!=l:
res[l]+=a[i]*b[j];res[l]%=mod
break
return res,m
mod=998244353
s=input();k=int(input())
if len(s)==1:
print(1 if str(k)==s else 0);exit()
a,b=aa(0)
print(a[k])