結果
問題 | No.2761 Substitute and Search |
ユーザー |
![]() |
提出日時 | 2024-05-17 22:20:54 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,063 bytes |
コンパイル時間 | 189 ms |
コンパイル使用メモリ | 82,528 KB |
実行使用メモリ | 849,168 KB |
最終ジャッジ日時 | 2024-05-17 22:21:05 |
合計ジャッジ時間 | 5,919 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 57 ms
65,656 KB |
testcase_01 | AC | 55 ms
63,932 KB |
testcase_02 | AC | 58 ms
64,796 KB |
testcase_03 | AC | 53 ms
64,232 KB |
testcase_04 | AC | 1,498 ms
87,588 KB |
testcase_05 | AC | 323 ms
86,312 KB |
testcase_06 | MLE | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
ソースコード
from string import ascii_lowercase n, l, q = map(int, input().split()) s = [input() for _ in range(n)] tree = {} for t in s: current = tree for c in t: if c in current: current[c][0] += 1 else: current[c] = [1, {}] current = current[c][1] char_cur = [[c for c in ascii_lowercase] for _ in range(l)] for _ in range(q): query = input().split() com = int(query[0]) if com == 1: k, c, d = query[1:] k = int(k) - 1 for i in range(26): if char_cur[k][i] == c: char_cur[k][i] = d else: t = query[1] cur = [tree] ans = 0 # count the number of words that start with t for i in range(len(t)): cur_next = [] ans = 0 for tr in cur: for key, value in tr.items(): if char_cur[i][ord(key) - ord('a')] == t[i]: cur_next.append(value[1]) ans += value[0] cur = cur_next print(ans)