結果
問題 | No.1677 mæx |
ユーザー | 👑 rin204 |
提出日時 | 2022-01-25 18:45:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 197 ms / 2,000 ms |
コード長 | 1,391 bytes |
コンパイル時間 | 260 ms |
コンパイル使用メモリ | 87,240 KB |
実行使用メモリ | 82,312 KB |
最終ジャッジ日時 | 2023-08-22 13:54:57 |
合計ジャッジ時間 | 6,221 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,420 KB |
testcase_01 | AC | 70 ms
71,640 KB |
testcase_02 | AC | 72 ms
71,472 KB |
testcase_03 | AC | 71 ms
71,472 KB |
testcase_04 | AC | 192 ms
80,388 KB |
testcase_05 | AC | 191 ms
80,492 KB |
testcase_06 | AC | 186 ms
80,148 KB |
testcase_07 | AC | 191 ms
80,204 KB |
testcase_08 | AC | 193 ms
80,368 KB |
testcase_09 | AC | 191 ms
79,672 KB |
testcase_10 | AC | 195 ms
79,952 KB |
testcase_11 | AC | 197 ms
80,188 KB |
testcase_12 | AC | 191 ms
80,564 KB |
testcase_13 | AC | 189 ms
80,304 KB |
testcase_14 | AC | 171 ms
79,564 KB |
testcase_15 | AC | 170 ms
79,424 KB |
testcase_16 | AC | 177 ms
79,628 KB |
testcase_17 | AC | 173 ms
79,664 KB |
testcase_18 | AC | 172 ms
79,556 KB |
testcase_19 | AC | 71 ms
71,576 KB |
testcase_20 | AC | 71 ms
71,440 KB |
testcase_21 | AC | 174 ms
82,312 KB |
ソースコード
MOD = 998244353 S = input() S = S.replace("max", "a") S = S.replace("mex", "e") S = S.replace("m?x", "o") S = S.replace(",", "") S = S.replace("(", "") S = S.replace(")", "") S = S[::-1] def mex(i, j): se = {i, j} x = 0 while x in se: x += 1 return x stack = [] for s in S: if s == "2": stack.append([0, 0, 1]) elif s == "1": stack.append([0, 1, 0]) elif s == "0": stack.append([1, 0, 0]) elif s == "?": stack.append([1, 1, 1]) elif s == "a": A = stack.pop() B = stack.pop() tmp = [0] * 3 for i in range(3): for j in range(3): tmp[max(i, j)] += A[i] * B[j] tmp[max(i, j)] %= MOD stack.append(tmp) elif s == "e": A = stack.pop() B = stack.pop() tmp = [0] * 3 for i in range(3): for j in range(3): tmp[mex(i, j)] += A[i] * B[j] tmp[mex(i, j)] %= MOD stack.append(tmp) else: A = stack.pop() B = stack.pop() tmp = [0] * 3 for i in range(3): for j in range(3): tmp[max(i, j)] += A[i] * B[j] tmp[max(i, j)] %= MOD tmp[mex(i, j)] += A[i] * B[j] tmp[mex(i, j)] %= MOD stack.append(tmp) k = int(input()) print(stack[0][k])