結果

問題 No.1725 [Cherry 3rd Tune D] 無言の言葉
ユーザー mkawa2mkawa2
提出日時 2021-10-29 23:21:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,025 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 298,288 KB
最終ジャッジ日時 2024-04-16 15:55:40
合計ジャッジ時間 18,437 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
55,296 KB
testcase_01 AC 47 ms
55,680 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 423 ms
112,208 KB
testcase_38 AC 417 ms
111,736 KB
testcase_39 AC 420 ms
112,564 KB
testcase_40 AC 419 ms
111,692 KB
testcase_41 AC 430 ms
112,540 KB
testcase_42 AC 45 ms
55,552 KB
testcase_43 AC 271 ms
165,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
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)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 1 << 63
# md = 998244353
md = 10**9+7

from bisect import bisect
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)
cc = cntc(s)
tc = cntc(t)
itc = cntc(t[::-1])

ww = [x]
aa = [1]
bb = [0]
cur = x
while ww[-1] < 10**9+5:
    cur = cur*2+y
    ww.append(cur)
    aa.append(aa[-1]*2)
    bb.append(bb[-1]*2+1)
# print(ww)
# print(aa)
# print(bb)

@lru_cache(None)
def solve(r, c):
    res = 0
    si = bisect(ww, r)-1
    rev = False
    for i in range(si, -1, -1):
        w = ww[i]
        if w > r:
            rev = False
            continue
        if w == r:
            res += aa[i]*cc[-1][c]+bb[i]*tc[-1][c]
            r = 0
            break
        res += aa[i]*cc[-1][c]+bb[i]*tc[-1][c]
        if r-w <= y:
            if rev:
                res += itc[r-w][c]
            else:
                res += tc[r-w][c]
            r = 0
            break
        else:
            res += tc[-1][c]
            r -= w+y
            rev = True

    res += cc[r][c]
    return res

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(r, c)-solve(l, c)
    print(ans)
0