結果

問題 No.1471 Sort Queries
コンテスト
ユーザー koheijkt
提出日時 2025-09-30 08:56:11
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 111 ms / 2,000 ms
+ 752µs
コード長 865 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 242 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 87,276 KB
最終ジャッジ日時 2026-07-15 07:50:55
合計ジャッジ時間 6,325 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
sys.set_int_max_str_digits(0)
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import product, combinations, permutations, groupby, accumulate
from heapq import heapify, heappop, heappush

N, Q = map(int, input().split())
S = input()
cnt = [[0] * (N + 1) for _ in range(26)]
for i, s in enumerate(S):
    cnt[ord(s) - 97][i + 1] += 1

for s in range(26):
    for i in range(N):
        cnt[s][i + 1] += cnt[s][i]

ansl = []
for _ in range(Q):
    l, r, x = map(int, input().split())
    memo = 0
    ans = 'a'
    for s in range(26):
        # cnt[s][r] - cnt[s][l - 1]
        memo += cnt[s][r] - cnt[s][l - 1]
        # びったりかオーバーランしたらその文字
        if memo >= x:
            ans = chr(97 + s)
            break
    ansl.append(ans)
print(*ansl, sep='\n')
0