結果
問題 | No.1725 [Cherry 3rd Tune D] 無言の言葉 |
ユーザー | Kude |
提出日時 | 2021-10-29 22:46:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 512 ms / 4,000 ms |
コード長 | 1,486 bytes |
コンパイル時間 | 317 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 158,592 KB |
最終ジャッジ日時 | 2024-04-16 15:35:16 |
合計ジャッジ時間 | 12,622 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,836 KB |
testcase_01 | AC | 43 ms
52,480 KB |
testcase_02 | AC | 65 ms
64,384 KB |
testcase_03 | AC | 100 ms
77,088 KB |
testcase_04 | AC | 60 ms
65,408 KB |
testcase_05 | AC | 65 ms
67,072 KB |
testcase_06 | AC | 111 ms
76,928 KB |
testcase_07 | AC | 105 ms
76,668 KB |
testcase_08 | AC | 113 ms
77,056 KB |
testcase_09 | AC | 53 ms
63,232 KB |
testcase_10 | AC | 106 ms
76,672 KB |
testcase_11 | AC | 55 ms
63,360 KB |
testcase_12 | AC | 131 ms
81,772 KB |
testcase_13 | AC | 134 ms
82,400 KB |
testcase_14 | AC | 267 ms
82,304 KB |
testcase_15 | AC | 142 ms
82,932 KB |
testcase_16 | AC | 148 ms
83,220 KB |
testcase_17 | AC | 176 ms
84,524 KB |
testcase_18 | AC | 284 ms
81,396 KB |
testcase_19 | AC | 158 ms
80,384 KB |
testcase_20 | AC | 136 ms
78,976 KB |
testcase_21 | AC | 267 ms
79,612 KB |
testcase_22 | AC | 326 ms
104,048 KB |
testcase_23 | AC | 326 ms
101,376 KB |
testcase_24 | AC | 243 ms
93,832 KB |
testcase_25 | AC | 377 ms
118,800 KB |
testcase_26 | AC | 322 ms
109,312 KB |
testcase_27 | AC | 342 ms
124,800 KB |
testcase_28 | AC | 436 ms
122,112 KB |
testcase_29 | AC | 414 ms
119,852 KB |
testcase_30 | AC | 399 ms
129,540 KB |
testcase_31 | AC | 276 ms
100,736 KB |
testcase_32 | AC | 512 ms
148,736 KB |
testcase_33 | AC | 508 ms
151,040 KB |
testcase_34 | AC | 485 ms
144,896 KB |
testcase_35 | AC | 453 ms
137,372 KB |
testcase_36 | AC | 474 ms
144,256 KB |
testcase_37 | AC | 298 ms
76,416 KB |
testcase_38 | AC | 310 ms
76,636 KB |
testcase_39 | AC | 311 ms
76,772 KB |
testcase_40 | AC | 300 ms
77,024 KB |
testcase_41 | AC | 299 ms
77,056 KB |
testcase_42 | AC | 40 ms
52,096 KB |
testcase_43 | AC | 259 ms
158,592 KB |
ソースコード
x = [ord(c) - 97 for c in input()] y = [ord(c) - 97 for c in input()] lx = len(x) ly = len(y) def get_acc(d): l = len(d) res1 = [[0] * (l + 1) for _ in range(26)] res2 = [[0] * (l + 1) for _ in range(26)] for i in range(l): for j in range(26): res1[j][i + 1] = res1[j][i] res1[d[i]][i + 1] += 1 for i in range(l)[::-1]: for j in range(26): res2[j][i] = res2[j][i + 1] res2[d[i]][i] += 1 return res1, res2 axl, axr = get_acc(x) ayl, ayr = get_acc(y) sz = [] l = lx cx = 1 cy = 0 while not sz or sz[-1][-1] < 10 ** 9: sz.append((l, cx, cy)) l = 2 * l + ly cx = 2 * cx cy = 2 * cy + 1 def f(r, c): flipped = False tx = ty = 0 for l, cx, cy in sz[::-1]: if r < l: if flipped: flipped = not flipped continue tx += cx ty += cy r -= l if r >= ly: ty += 1 r -= ly if not flipped: flipped = not flipped continue res = tx * axl[c][-1] + ty * ayl[c][-1] if flipped: res += ayr[c][ly - r] else: res += ayl[c][r] return res res = tx * axl[c][-1] + ty * ayl[c][-1] if flipped: res += axr[c][lx - r] else: res += axl[c][r] return res for _ in range(int(input())): l, r, c = input().split() c = ord(c) - 97 print(f(int(r), c) - f(int(l) - 1, c))