結果
| 問題 |
No.1471 Sort Queries
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2022-08-03 17:18:33 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 2,000 ms |
| コード長 | 797 bytes |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 82,460 KB |
| 実行使用メモリ | 86,656 KB |
| 最終ジャッジ日時 | 2024-09-13 10:33:37 |
| 合計ジャッジ時間 | 6,636 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
N, Q = map(int,input().split())
S = input()
lrx = [list(map(int,input().split( ))) for _ in range(Q)]
cs = {
"a":1,"b":2,"c":3,"d":4,"e":5,
"f":6,"g":7,"h":8,"i":9,"j":10,
"k":11,"l":12,"m":13,"n":14,"o":15,
"p":16,"q":17,"r":18,"s":19,"t":20,
"u":21,"v":22,"w":23,"x":24,"y":25,
"z":26}
for i in cs:
cs[i] = 0
al = "abcdefghijklmnopqrstuvwxyz"
sum = [{} for _ in range(N+1)]
for i in range(N+1):
for j in cs:
sum[i][j] = 0
if i == 0:
continue
for j in cs:
sum[i][j] = sum[i-1][j]
sum[i][S[i-1]] += 1
for i in range(Q):
l,r,x = lrx[i]
for j in cs:
cs[j] = sum[r][j] - sum[l-1][j]
now = 0
for j in range(len(al)):
now += cs[al[j]]
if now >= x:
print(al[j])
break
momoyuu