結果
問題 | No.1471 Sort Queries |
ユーザー | mkawa2 |
提出日時 | 2021-04-09 21:35:57 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
AC
|
実行時間 | 336 ms / 2,000 ms |
コード長 | 2,084 bytes |
コンパイル時間 | 676 ms |
コンパイル使用メモリ | 10,940 KB |
実行使用メモリ | 10,560 KB |
最終ジャッジ日時 | 2023-09-07 10:15:20 |
合計ジャッジ時間 | 7,735 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 17 ms
8,008 KB |
testcase_01 | AC | 16 ms
8,012 KB |
testcase_02 | AC | 17 ms
8,160 KB |
testcase_03 | AC | 17 ms
8,032 KB |
testcase_04 | AC | 18 ms
8,064 KB |
testcase_05 | AC | 17 ms
8,100 KB |
testcase_06 | AC | 16 ms
8,040 KB |
testcase_07 | AC | 18 ms
8,088 KB |
testcase_08 | AC | 18 ms
8,012 KB |
testcase_09 | AC | 18 ms
8,180 KB |
testcase_10 | AC | 17 ms
8,092 KB |
testcase_11 | AC | 17 ms
8,176 KB |
testcase_12 | AC | 18 ms
8,088 KB |
testcase_13 | AC | 87 ms
9,404 KB |
testcase_14 | AC | 89 ms
9,340 KB |
testcase_15 | AC | 137 ms
9,276 KB |
testcase_16 | AC | 84 ms
8,640 KB |
testcase_17 | AC | 73 ms
9,352 KB |
testcase_18 | AC | 55 ms
9,292 KB |
testcase_19 | AC | 83 ms
8,760 KB |
testcase_20 | AC | 136 ms
9,388 KB |
testcase_21 | AC | 79 ms
9,196 KB |
testcase_22 | AC | 67 ms
9,168 KB |
testcase_23 | AC | 191 ms
9,916 KB |
testcase_24 | AC | 181 ms
9,984 KB |
testcase_25 | AC | 274 ms
10,140 KB |
testcase_26 | AC | 196 ms
9,616 KB |
testcase_27 | AC | 220 ms
10,452 KB |
testcase_28 | AC | 224 ms
10,432 KB |
testcase_29 | AC | 186 ms
9,620 KB |
testcase_30 | AC | 176 ms
9,836 KB |
testcase_31 | AC | 271 ms
9,792 KB |
testcase_32 | AC | 282 ms
9,480 KB |
testcase_33 | AC | 288 ms
10,496 KB |
testcase_34 | AC | 336 ms
10,560 KB |
testcase_35 | AC | 327 ms
10,544 KB |
testcase_36 | AC | 200 ms
10,448 KB |
testcase_37 | AC | 194 ms
10,464 KB |
testcase_38 | AC | 73 ms
10,400 KB |
testcase_39 | AC | 266 ms
10,456 KB |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def FI(): return float(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] dij = [(0, 1), (1, 0), (1, 1), (1, -1)] inf = 10**19 # md = 998244353 md = 10**9+7 class BitSum: def __init__(self, n): self.n = n+1 self.table = [0]*self.n def add(self, i, x): i += 1 while i < self.n: self.table[i] += x i += i & -i # [0,i]の和 def sum(self, i): i += 1 res = 0 while i > 0: res += self.table[i] i -= i & -i return res # [l,r)の和 def sumlr(self, l, r): if l >= r: return 0 if l == 0: return self.sum(r-1) return self.sum(r-1)-self.sum(l-1) # 数列を度数分布とみたときに、x番目がどのインデックスにあるかを返す # xが大きすぎるときは配列の長さnを返す def rank(self, x): idx = 0 for lv in range((self.n-1).bit_length()-1, -1, -1): mid = idx+(1 << lv) if mid >= self.n: continue if self.table[mid] < x: x -= self.table[mid] idx += 1 << lv return idx n, q = LI() s = BI() bit = [BitSum(n) for _ in range(26)] for i, c in enumerate(s): c -= 97 bit[c].add(i, 1) for _ in range(q): l,r,x=LI() now=0 for c in range(26): now+=bit[c].sumlr(l-1,r) if now>=x: print(chr(c+97)) break