結果

問題 No.2716 Falcon Method
ユーザー hato336hato336
提出日時 2024-04-05 21:58:08
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 954 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 205,324 KB
最終ジャッジ日時 2024-04-05 21:58:20
合計ジャッジ時間 8,244 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
84,920 KB
testcase_01 RE -
testcase_02 AC 108 ms
85,048 KB
testcase_03 AC 111 ms
85,048 KB
testcase_04 AC 127 ms
85,048 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 128 ms
88,760 KB
testcase_08 AC 129 ms
88,760 KB
testcase_09 AC 130 ms
88,760 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 350 ms
200,568 KB
testcase_13 AC 320 ms
198,476 KB
testcase_14 AC 327 ms
185,732 KB
testcase_15 AC 318 ms
192,980 KB
testcase_16 AC 348 ms
185,648 KB
testcase_17 AC 354 ms
194,588 KB
testcase_18 AC 354 ms
194,824 KB
testcase_19 AC 352 ms
185,440 KB
testcase_20 AC 311 ms
192,816 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 341 ms
194,172 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 368 ms
199,028 KB
testcase_28 AC 372 ms
199,024 KB
権限があれば一括ダウンロードができます

ソースコード

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