結果

問題 No.1471 Sort Queries
ユーザー terasaterasa
提出日時 2022-06-06 17:19:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 81,500 KB
実行使用メモリ 81,560 KB
最終ジャッジ日時 2023-10-21 03:38:48
合計ジャッジ時間 7,925 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
60,852 KB
testcase_01 AC 53 ms
60,852 KB
testcase_02 AC 53 ms
60,852 KB
testcase_03 AC 64 ms
67,960 KB
testcase_04 AC 55 ms
62,936 KB
testcase_05 AC 54 ms
60,888 KB
testcase_06 AC 54 ms
60,888 KB
testcase_07 AC 53 ms
60,888 KB
testcase_08 AC 66 ms
68,380 KB
testcase_09 AC 56 ms
63,188 KB
testcase_10 AC 54 ms
62,948 KB
testcase_11 AC 55 ms
62,948 KB
testcase_12 AC 63 ms
68,000 KB
testcase_13 AC 137 ms
78,828 KB
testcase_14 AC 130 ms
78,552 KB
testcase_15 AC 137 ms
78,800 KB
testcase_16 AC 100 ms
77,304 KB
testcase_17 AC 134 ms
78,808 KB
testcase_18 AC 127 ms
78,556 KB
testcase_19 AC 107 ms
77,532 KB
testcase_20 AC 136 ms
78,792 KB
testcase_21 AC 129 ms
78,596 KB
testcase_22 AC 127 ms
78,560 KB
testcase_23 AC 177 ms
80,536 KB
testcase_24 AC 174 ms
80,536 KB
testcase_25 AC 181 ms
80,636 KB
testcase_26 AC 153 ms
79,588 KB
testcase_27 AC 198 ms
81,480 KB
testcase_28 AC 196 ms
81,308 KB
testcase_29 AC 160 ms
79,676 KB
testcase_30 AC 167 ms
80,200 KB
testcase_31 AC 172 ms
80,068 KB
testcase_32 AC 157 ms
79,412 KB
testcase_33 AC 198 ms
81,552 KB
testcase_34 AC 202 ms
81,556 KB
testcase_35 AC 204 ms
81,560 KB
testcase_36 AC 197 ms
81,560 KB
testcase_37 AC 198 ms
81,556 KB
testcase_38 AC 188 ms
81,212 KB
testcase_39 AC 186 ms
81,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import copy
import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict
import bisect

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


def index_lt(a, x):
    'return largest index s.t. A[i] < x or -1 if it does not exist'
    return bisect.bisect_left(a, x) - 1


def index_le(a, x):
    'return largest index s.t. A[i] <= x or -1 if it does not exist'
    return bisect.bisect_right(a, x) - 1


def index_gt(a, x):
    'return smallest index s.t. A[i] > x or len(a) if it does not exist'
    return bisect.bisect_right(a, x)


def index_ge(a, x):
    'return smallest index s.t. A[i] >= x or len(a) if it does not exist'
    return bisect.bisect_left(a, x)


N, Q = map(int, input().split())
S = input()[:-1]
C = []
acc = [0] * 26
for c in S:
    acc[ord(c) - ord('a')] += 1
    C.append(copy.deepcopy(acc))


for _ in range(Q):
    l, r, x = map(int, input().split())
    l -= 1
    r -= 1
    acc = 0
    for i in range(26):
        acc += C[r][i] - (C[l - 1][i] if l > 0 else 0)
        if acc >= x:
            print(chr(ord('a') + i))
            break
0