結果

問題 No.2716 Falcon Method
ユーザー ニックネームニックネーム
提出日時 2024-04-05 22:04:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,403 ms / 2,000 ms
コード長 558 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 29,696 KB
最終ジャッジ日時 2024-04-05 22:04:38
合計ジャッジ時間 19,733 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,112 KB
testcase_01 AC 30 ms
10,112 KB
testcase_02 AC 32 ms
10,112 KB
testcase_03 AC 31 ms
10,112 KB
testcase_04 AC 33 ms
10,112 KB
testcase_05 AC 32 ms
10,112 KB
testcase_06 AC 39 ms
10,240 KB
testcase_07 AC 39 ms
10,240 KB
testcase_08 AC 39 ms
10,240 KB
testcase_09 AC 38 ms
10,240 KB
testcase_10 AC 39 ms
10,240 KB
testcase_11 AC 1,077 ms
28,928 KB
testcase_12 AC 971 ms
28,920 KB
testcase_13 AC 806 ms
28,956 KB
testcase_14 AC 1,117 ms
25,856 KB
testcase_15 AC 857 ms
27,984 KB
testcase_16 AC 964 ms
25,984 KB
testcase_17 AC 1,149 ms
26,604 KB
testcase_18 AC 1,319 ms
27,248 KB
testcase_19 AC 1,013 ms
25,572 KB
testcase_20 AC 814 ms
27,724 KB
testcase_21 AC 937 ms
26,348 KB
testcase_22 AC 1,174 ms
29,696 KB
testcase_23 AC 1,350 ms
29,696 KB
testcase_24 AC 1,203 ms
29,696 KB
testcase_25 AC 30 ms
10,112 KB
testcase_26 AC 29 ms
10,112 KB
testcase_27 AC 1,403 ms
29,696 KB
testcase_28 AC 1,366 ms
29,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from bisect import bisect_left
n,q = map(int,input().split())
s = input()*2; d = [0]; r = [0]
for v in s:
    d.append(d[-1]); r.append(r[-1])
    if v=="D": d[-1] += 1
    else: r[-1] += 1
for _ in range(q):
    h,w,p = map(int,input().split())
    if d[n]: d1,d2 = divmod(h,d[n])
    else: d1 = d2 = n
    if d1>0==d2: d1 -= 1; d2 += d[n]
    d3 = max(bisect_left(d,d[p]+d2),p)
    if r[n]: r1,r2 = divmod(w,r[n])
    else: r1 = r2 = n
    if r1>0==r2: r1 -= 1; r2 += r[n]
    r3 = max(bisect_left(r,r[p]+r2),p)
    print(d3%n if (d1,d3)<(r1,r3) else r3%n)
0