結果
問題 | No.1725 [Cherry 3rd Tune D] 無言の言葉 |
ユーザー | mkawa2 |
提出日時 | 2021-10-30 13:45:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,884 bytes |
コンパイル時間 | 429 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 621,256 KB |
最終ジャッジ日時 | 2024-10-07 13:38:39 |
合計ジャッジ時間 | 49,341 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
11,136 KB |
testcase_01 | AC | 33 ms
11,008 KB |
testcase_02 | AC | 49 ms
12,972 KB |
testcase_03 | AC | 89 ms
18,536 KB |
testcase_04 | AC | 42 ms
12,160 KB |
testcase_05 | AC | 48 ms
13,180 KB |
testcase_06 | AC | 250 ms
40,480 KB |
testcase_07 | AC | 104 ms
20,624 KB |
testcase_08 | AC | 189 ms
29,324 KB |
testcase_09 | AC | 38 ms
12,032 KB |
testcase_10 | AC | 103 ms
20,064 KB |
testcase_11 | AC | 38 ms
12,032 KB |
testcase_12 | AC | 295 ms
52,924 KB |
testcase_13 | AC | 311 ms
54,688 KB |
testcase_14 | AC | 1,685 ms
201,604 KB |
testcase_15 | AC | 360 ms
61,780 KB |
testcase_16 | AC | 464 ms
78,276 KB |
testcase_17 | AC | 710 ms
112,584 KB |
testcase_18 | AC | 2,012 ms
281,036 KB |
testcase_19 | AC | 585 ms
90,480 KB |
testcase_20 | AC | 250 ms
39,612 KB |
testcase_21 | AC | 1,980 ms
273,616 KB |
testcase_22 | AC | 2,289 ms
315,120 KB |
testcase_23 | AC | 2,407 ms
314,084 KB |
testcase_24 | AC | 1,592 ms
243,772 KB |
testcase_25 | AC | 3,024 ms
425,040 KB |
testcase_26 | AC | 2,340 ms
338,988 KB |
testcase_27 | AC | 2,862 ms
422,432 KB |
testcase_28 | AC | 3,527 ms
459,824 KB |
testcase_29 | AC | 3,231 ms
443,132 KB |
testcase_30 | AC | 3,236 ms
468,556 KB |
testcase_31 | AC | 2,021 ms
284,148 KB |
testcase_32 | MLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | MLE | - |
testcase_36 | MLE | - |
testcase_37 | AC | 3,336 ms
283,916 KB |
testcase_38 | AC | 3,342 ms
283,920 KB |
testcase_39 | AC | 3,338 ms
284,144 KB |
testcase_40 | AC | 3,340 ms
283,760 KB |
testcase_41 | AC | 3,331 ms
284,044 KB |
testcase_42 | AC | 32 ms
11,008 KB |
testcase_43 | AC | 1,274 ms
121,216 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 18446744073709551615 # inf = 4294967295 md = 10**9+7 # md = 998244353 from collections import Counter from functools import lru_cache def cntc(s): res = [] cnt = Counter() res.append(cnt.copy()) for c in s: c = ord(c)-97 cnt[c] += 1 res.append(cnt.copy()) return res s = SI() t = SI() x = len(s) y = len(t) sc = cntc(s) tc = cntc(t) isc = cntc(s[::-1]) itc = cntc(t[::-1]) ww = [x] aa = [1] bb = [0] while ww[-1] < 10**9+5: ww.append(ww[-1]*2+y) aa.append(aa[-1]*2) bb.append(bb[-1]*2+1) # print(ww) # print(aa) # print(bb) @lru_cache(None) def solve(lv, s, c, rev=False): if s == ww[lv]: return sc[-1][c]*aa[lv]+tc[-1][c]*bb[lv] if lv == 0: if rev: return isc[s][c] return sc[s][c] lw = ww[lv-1] if s <= lw: return solve(lv-1, s, c, False) left = sc[-1][c]*aa[lv-1]+tc[-1][c]*bb[lv-1] if s <= lw+y: if rev: return left+itc[s-lw][c] return left+tc[s-lw][c] if rev: left+itc[-1][c]+solve(lv-1, s-lw-y, c, True) return left+tc[-1][c]+solve(lv-1, s-lw-y, c, True) for _ in range(II()): l, r, c = SI().split() l = int(l)-1 r = int(r) c = ord(c)-97 # print(solve(r, c),solve(l, c)) ans = solve(len(ww)-1, r, c)-solve(len(ww)-1, l, c) print(ans)