結果
| 問題 | No.1471 Sort Queries | 
| コンテスト | |
| ユーザー |  学ぶマン | 
| 提出日時 | 2025-09-30 08:56:11 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 101 ms / 2,000 ms | 
| コード長 | 865 bytes | 
| コンパイル時間 | 5,140 ms | 
| コンパイル使用メモリ | 81,784 KB | 
| 実行使用メモリ | 79,488 KB | 
| 最終ジャッジ日時 | 2025-09-30 08:56:28 | 
| 合計ジャッジ時間 | 9,500 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 37 | 
ソースコード
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')
            
            
            
        