結果
問題 | No.1677 mæx |
ユーザー | titia |
提出日時 | 2021-09-10 23:20:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,933 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 297,628 KB |
最終ジャッジ日時 | 2024-06-12 04:03:20 |
合計ジャッジ時間 | 4,234 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | AC | 35 ms
53,412 KB |
testcase_04 | OLE | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
ソースコード
import sys input = sys.stdin.readline sys.setrecursionlimit(2*10**5) S=input().strip() K=int(input()) mod=998244353 if len(S)==1: x=int(S) if K==x: print(1) else: print(0) exit() def calc(S,x): print(S,x) if len(S)==1: if S=="?": return 1 y=int(S) if y==x: return 1 else: return 0 now=0 for i in range(4,len(S)): if S[i]=="(": now+=1 elif S[i]==")": now-=1 elif S[i]=="," and now==0: kom=i break T=S[4:kom] U=S[kom+1:-1] if S[0:2]=="max": if x==0: return calc(T,0)*calc(U,0)%mod elif x==1: return (calc(T,0)*calc(U,1)%mod+calc(T,1)*calc(U,0)%mod+calc(T,1)*calc(U,1)%mod)%mod else: return (calc(T,0)*calc(U,2)%mod+calc(T,1)*calc(U,2)%mod+calc(T,2)*calc(U,0)%mod+calc(T,2)*calc(U,1)%mod+calc(T,2)*calc(U,2)%mod)%mod elif S[0:2]=="mex": if x==0: return calc(T,1)*calc(U,1)%mod + calc(T,1)*calc(U,2)%mod +calc(T,2)*calc(U,1)%mod + calc(T,2)*calc(U,2)%mod elif x==1: return calc(T,0)*calc(U,0)%mod else: return (calc(T,0)*calc(U,1)%mod+calc(T,1)*calc(U,0)%mod)%mod else: if x==0: return calc(T,0)*calc(U,0)%mod +calc(T,1)*calc(U,1)%mod + calc(T,1)*calc(U,2)%mod +calc(T,2)*calc(U,1)%mod + calc(T,2)*calc(U,2)%mod elif x==1: return (calc(T,0)*calc(U,1)%mod+calc(T,1)*calc(U,0)%mod+calc(T,1)*calc(U,1)%mod)%mod + calc(T,0)*calc(U,0)%mod else: return (calc(T,0)*calc(U,2)%mod+calc(T,1)*calc(U,2)%mod+calc(T,2)*calc(U,0)%mod+calc(T,2)*calc(U,1)%mod+calc(T,2)*calc(U,2)%mod)%mod + (calc(T,0)*calc(U,1)%mod+calc(T,1)*calc(U,0)%mod)%mod print(calc(S,K)%mod)