結果
問題 | No.1677 mæx |
ユーザー | rlangevin |
提出日時 | 2023-02-06 23:47:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 311 ms / 2,000 ms |
コード長 | 1,495 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 91,464 KB |
最終ジャッジ日時 | 2024-07-05 01:04:53 |
合計ジャッジ時間 | 5,340 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
51,968 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 38 ms
52,480 KB |
testcase_03 | AC | 38 ms
52,224 KB |
testcase_04 | AC | 311 ms
90,764 KB |
testcase_05 | AC | 298 ms
90,404 KB |
testcase_06 | AC | 309 ms
90,600 KB |
testcase_07 | AC | 294 ms
90,124 KB |
testcase_08 | AC | 294 ms
89,720 KB |
testcase_09 | AC | 295 ms
90,196 KB |
testcase_10 | AC | 300 ms
90,552 KB |
testcase_11 | AC | 281 ms
90,356 KB |
testcase_12 | AC | 280 ms
89,956 KB |
testcase_13 | AC | 291 ms
90,872 KB |
testcase_14 | AC | 124 ms
88,408 KB |
testcase_15 | AC | 125 ms
88,848 KB |
testcase_16 | AC | 129 ms
88,256 KB |
testcase_17 | AC | 135 ms
88,700 KB |
testcase_18 | AC | 125 ms
88,476 KB |
testcase_19 | AC | 39 ms
52,272 KB |
testcase_20 | AC | 39 ms
51,840 KB |
testcase_21 | AC | 97 ms
91,464 KB |
ソースコード
mod = 998244353 def lst(n): if n == "0": return [1, 0, 0] elif n == "1": return [0, 1, 0] elif n == "2": return [0, 0, 1] elif n == "?": return [1, 1, 1] else: return n def calc(X, Y, ae): temp = [0, 0, 0] if ae == "a": temp[2] = sum(X) * Y[2] + sum(Y) * X[2] - X[2] * Y[2] temp[1] = (X[1] + X[0]) * (Y[1] + Y[0]) - Y[0] * X[0] temp[0] = X[0] * Y[0] elif ae == "e": temp[0] = (X[1] + X[2]) * (Y[1] + Y[2]) temp[1] = (X[0] + X[2]) * (Y[0] + Y[2]) - X[2] * Y[2] temp[2] = X[0] * Y[1] + X[1] * Y[0] else: temp[0] = (X[1] + X[2]) * (Y[1] + Y[2]) + X[0] * Y[0] temp[1] = (X[0] + X[2]) * (Y[0] + Y[2]) - X[2] * Y[2] + (X[1] + X[0]) * (Y[1] + Y[0]) - Y[0] * X[0] temp[2] = X[0] * Y[1] + X[1] * Y[0] + sum(X) * Y[2] + sum(Y) * X[2] - X[2] * Y[2] temp[0] %= mod temp[1] %= mod temp[2] %= mod # print("calc_test", X, Y, temp, ae) return temp S = list(input()) K = int(input()) stack = [] for s in S: if s == "m" or s == "x": continue elif s != ")": stack.append(s) else: A = lst(stack.pop()) stack.pop() B = lst(stack.pop()) stack.pop() ae = stack.pop() stack.append(calc(A, B, ae)) # print("test", s, stack) if stack[0] in ["0", "1", "2"]: if K == int(stack[0]): print(1) else: print(0) else: print(stack[0][K])