結果

問題 No.2716 Falcon Method
ユーザー hato336hato336
提出日時 2024-04-05 21:59:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 480 ms / 2,000 ms
コード長 998 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 205,320 KB
最終ジャッジ日時 2024-04-05 21:59:17
合計ジャッジ時間 10,178 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 133 ms
85,048 KB
testcase_01 AC 126 ms
85,048 KB
testcase_02 AC 125 ms
85,048 KB
testcase_03 AC 126 ms
85,048 KB
testcase_04 AC 155 ms
85,048 KB
testcase_05 AC 129 ms
85,048 KB
testcase_06 AC 156 ms
88,760 KB
testcase_07 AC 154 ms
88,760 KB
testcase_08 AC 156 ms
88,760 KB
testcase_09 AC 157 ms
88,760 KB
testcase_10 AC 153 ms
88,760 KB
testcase_11 AC 444 ms
205,320 KB
testcase_12 AC 384 ms
200,564 KB
testcase_13 AC 389 ms
198,468 KB
testcase_14 AC 417 ms
185,736 KB
testcase_15 AC 370 ms
192,984 KB
testcase_16 AC 385 ms
185,648 KB
testcase_17 AC 456 ms
194,592 KB
testcase_18 AC 431 ms
194,824 KB
testcase_19 AC 383 ms
185,436 KB
testcase_20 AC 377 ms
192,816 KB
testcase_21 AC 354 ms
186,180 KB
testcase_22 AC 406 ms
203,364 KB
testcase_23 AC 435 ms
194,168 KB
testcase_24 AC 405 ms
203,360 KB
testcase_25 AC 132 ms
85,048 KB
testcase_26 AC 128 ms
85,048 KB
testcase_27 AC 480 ms
199,024 KB
testcase_28 AC 448 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 if d != 0 else 10**18,w//r if r != 0 else 10**18)
    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