結果

問題 No.1471 Sort Queries
ユーザー 330Xs
提出日時 2022-02-03 16:41:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 451 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 77,312 KB
最終ジャッジ日時 2024-06-11 09:57:31
合計ジャッジ時間 7,395 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n,m = map(int,input().split())
s = list(map(str,input()))
ss = sorted(s)
d = defaultdict(list)
for i in range(n):
    d[s[i]].append(i+1)

dd = sorted(d.items())
for _ in range(m):
    a,b,c = map(int,input().split())
    cnt = 0
    flag = False
    for key,lis in dd:
        for v in lis:
            if(a <= v <= b):
                cnt += 1
            if(cnt == c):
                print(key)
                flag = True
                break
        if(flag):
            break
            
0