結果

問題 No.2716 Falcon Method
ユーザー hato336hato336
提出日時 2024-04-05 21:58:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 954 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 82,456 KB
実行使用メモリ 205,956 KB
最終ジャッジ日時 2024-10-01 02:14:45
合計ジャッジ時間 9,395 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
input = sys.stdin.readline
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n,q = map(int,input().split())
s = list(input().rstrip())
d = s.count('D')
r = s.count('R')
dd = []
rr = []
for i in range(n):
    dd.append(1 if s[i] == 'D' else 0)
    rr.append(1 if s[i] == 'R' else 0)
for i in range(n):
    dd.append(1 if s[i] == 'D' else 0)
    rr.append(1 if s[i] == 'R' else 0)
dd = list(itertools.accumulate(dd))
rr = list(itertools.accumulate(rr))



for i in range(q):
    h,w,p = map(int,input().split())
    z = min(h//d,w//r)
    h = h - d * z
    w = w - r * z
    if h == 0 or w == 0:
        h += d
        w += r
    #print(h,w)
    di = bisect.bisect_left(dd,(dd[p-1] if p != 0 else 0)+h)
    ri = bisect.bisect_left(rr,(rr[p-1] if p != 0 else 0)+w)
    #print(di,ri)
    j = min(di,ri)+1
    print((j)%n)
0