結果

問題 No.2716 Falcon Method
ユーザー rin204rin204
提出日時 2024-04-07 10:54:35
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 582 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 112,404 KB
最終ジャッジ日時 2024-04-07 10:54:43
合計ジャッジ時間 7,189 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,460 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 39 ms
53,460 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 67 ms
66,008 KB
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 302 ms
106,016 KB
testcase_13 WA -
testcase_14 AC 338 ms
106,108 KB
testcase_15 AC 272 ms
105,424 KB
testcase_16 AC 309 ms
102,296 KB
testcase_17 AC 365 ms
105,408 KB
testcase_18 WA -
testcase_19 AC 303 ms
105,808 KB
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 381 ms
102,324 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 424 ms
105,884 KB
testcase_28 AC 391 ms
105,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, Q = map(int, input().split())
S = input()
H = [0]
W = [0]

H2 = [0]
W2 = [0]
for i, s in enumerate(S, 1):
    if s == "D":
        H.append(i)
        H2.append(H2[-1] + 1)
        W2.append(W2[-1])
    else:
        W.append(i)
        H2.append(H2[-1])
        W2.append(W2[-1] + 1)

for _ in range(Q):
    h, w, p = map(int, input().split())
    h += H2[p]
    w += W2[p]
    mi = min(h // H2[-1], w // W2[-1])
    h -= mi * H2[-1]
    w -= mi * W2[-1]
    ans = n
    if h < H2[-1]:
        ans = min(ans, H[h])
    if w < W2[-1]:
        ans = min(ans, W[w])
    print(ans)
0