結果

問題 No.1471 Sort Queries
ユーザー harurunharurun
提出日時 2021-04-09 22:29:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,557 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 13,772 KB
最終ジャッジ日時 2023-09-07 11:58:57
合計ジャッジ時間 4,007 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,516 KB
testcase_01 AC 19 ms
8,460 KB
testcase_02 AC 19 ms
8,516 KB
testcase_03 AC 19 ms
8,588 KB
testcase_04 AC 19 ms
8,444 KB
testcase_05 AC 18 ms
8,616 KB
testcase_06 AC 18 ms
8,500 KB
testcase_07 AC 19 ms
8,644 KB
testcase_08 AC 19 ms
8,612 KB
testcase_09 AC 19 ms
8,488 KB
testcase_10 AC 19 ms
8,564 KB
testcase_11 AC 19 ms
8,596 KB
testcase_12 AC 19 ms
8,492 KB
testcase_13 AC 33 ms
10,376 KB
testcase_14 AC 32 ms
10,104 KB
testcase_15 AC 40 ms
10,664 KB
testcase_16 AC 30 ms
9,524 KB
testcase_17 AC 31 ms
10,112 KB
testcase_18 AC 28 ms
9,816 KB
testcase_19 AC 31 ms
9,544 KB
testcase_20 AC 40 ms
10,820 KB
testcase_21 AC 31 ms
10,040 KB
testcase_22 AC 29 ms
9,984 KB
testcase_23 AC 48 ms
11,800 KB
testcase_24 AC 47 ms
11,820 KB
testcase_25 AC 61 ms
12,724 KB
testcase_26 AC 50 ms
11,556 KB
testcase_27 AC 55 ms
12,880 KB
testcase_28 AC 54 ms
12,792 KB
testcase_29 AC 47 ms
11,516 KB
testcase_30 AC 46 ms
11,864 KB
testcase_31 AC 61 ms
12,404 KB
testcase_32 AC 61 ms
12,192 KB
testcase_33 AC 68 ms
13,672 KB
testcase_34 AC 71 ms
13,652 KB
testcase_35 AC 72 ms
13,616 KB
testcase_36 AC 66 ms
12,884 KB
testcase_37 AC 66 ms
12,944 KB
testcase_38 AC 54 ms
13,764 KB
testcase_39 AC 69 ms
13,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

class INPUT:
  def __init__(self):
    self.l=open(0).read().split()[::-1]
    self.length=len(self.l)
    return

  def stream(self,k=1,f=int,f2=False):
    assert(-1<k)
    m=self.length
    if m==0 or m<k:
      raise Exception("There is no input!")
    elif f!=str:
      if k==0:
        self.length=0
        return list(map(f,self.l[::-1]))
      if k==1 and not f2:
        self.length-=1
        return f(self.l.pop())
      if k==1 and f2:
        self.length-=1
        return [f(self.l.pop())]
      ret=[]
      for _ in [0]*k:
        ret.append(f(self.l.pop()))
      self.length-=k
      return ret
    else:
      if k==0:
        self.length=0
        return self.l[::-1]
      if k==1 and not f2:
        self.length-=1
        return self.l.pop()
      if k==1 and f2:
        self.length-=1
        return [self.l.pop()]
      ret=[]
      for _ in [0]*k:
        ret.append(self.l.pop())
      self.length-=k
      return ret
pin=INPUT().stream

"""
pin(number[default:1],f[default:int],f2[default:False])
if number==0 -> return left all
listを変数で受け取るとき、必ずlistをTrueにすること。
"""
from sys import stderr
from copy import copy
we=stderr.write
def main():
  N,Q=pin(2)
  S=list(pin(1,str))
  d=[]
  a=[0]*26
  d.append(copy(a))
  for i in S:
    a[ord(i)-97]+=1
    d.append(copy(a))
  for _ in [0]*Q:
    L,R,X=pin(3)
    #print(d[R],d[L-1])
    db=[]
    for i in range(26):
      t=d[R][i]-d[L-1][i]
      db.append(t)
      X-=t
      if X<=0:
        print(chr(97+i))
        break
  return
main()
0