結果

問題 No.1471 Sort Queries
ユーザー FromBooskaFromBooska
提出日時 2023-09-25 12:15:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 922 bytes
コンパイル時間 1,312 ms
コンパイル使用メモリ 86,488 KB
実行使用メモリ 80,792 KB
最終ジャッジ日時 2023-09-25 12:15:55
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,432 KB
testcase_01 AC 72 ms
71,124 KB
testcase_02 AC 71 ms
71,432 KB
testcase_03 AC 90 ms
76,192 KB
testcase_04 AC 79 ms
71,284 KB
testcase_05 AC 72 ms
71,240 KB
testcase_06 AC 72 ms
71,444 KB
testcase_07 AC 72 ms
71,164 KB
testcase_08 AC 80 ms
76,688 KB
testcase_09 AC 75 ms
76,172 KB
testcase_10 AC 70 ms
71,416 KB
testcase_11 AC 73 ms
71,180 KB
testcase_12 AC 77 ms
76,312 KB
testcase_13 AC 105 ms
76,868 KB
testcase_14 AC 101 ms
77,004 KB
testcase_15 AC 111 ms
78,800 KB
testcase_16 AC 110 ms
77,552 KB
testcase_17 AC 105 ms
76,912 KB
testcase_18 AC 97 ms
76,992 KB
testcase_19 AC 102 ms
76,844 KB
testcase_20 AC 110 ms
78,848 KB
testcase_21 AC 111 ms
77,500 KB
testcase_22 AC 102 ms
76,908 KB
testcase_23 AC 129 ms
80,028 KB
testcase_24 AC 127 ms
79,844 KB
testcase_25 AC 154 ms
80,192 KB
testcase_26 AC 127 ms
79,164 KB
testcase_27 AC 131 ms
80,396 KB
testcase_28 AC 130 ms
80,384 KB
testcase_29 AC 126 ms
79,488 KB
testcase_30 AC 116 ms
79,792 KB
testcase_31 AC 132 ms
79,672 KB
testcase_32 AC 136 ms
79,296 KB
testcase_33 AC 164 ms
80,604 KB
testcase_34 AC 141 ms
80,688 KB
testcase_35 AC 141 ms
80,792 KB
testcase_36 AC 140 ms
80,588 KB
testcase_37 AC 145 ms
80,580 KB
testcase_38 AC 150 ms
80,732 KB
testcase_39 AC 125 ms
80,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# その区間にどのアルファベットが何個あるかわかればいい
# ということはアルファベットのカウントをすればいい
# defaultdict(list)でもいいだろうがここではcount表を作る

N, Q = map(int, input().split())
S = input()

alphabets = 'abcdefghijklmnopqrstuvwxyz'
dic = {}
for i in range(26):
    dic[alphabets[i]] = i

count = [[0]*26 for i in range(N+1)]

for i in range(1, N+1):
    s = S[i-1]
    s_num = dic[s]
    for j in range(26):
        if j == s_num:
            count[i][j] = count[i-1][j]+1
        else:
            count[i][j] = count[i-1][j]
    #print(count[i])
    
for q in range(Q):
    l, r, x = map(int, input().split())
    x_remainder = x
    for k in range(26):
        cnt = count[r][k] - count[l-1][k]
        if cnt < x_remainder:
            x_remainder -= cnt
        else:
            print(alphabets[k])
            break
    
    
    
0