結果

問題 No.2716 Falcon Method
ユーザー 👑 rin204rin204
提出日時 2024-04-07 10:56:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 715 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 117,692 KB
最終ジャッジ日時 2024-04-07 10:56:44
合計ジャッジ時間 7,969 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 WA -
testcase_03 AC 36 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 46 ms
53,460 KB
testcase_06 AC 61 ms
66,044 KB
testcase_07 WA -
testcase_08 AC 61 ms
66,008 KB
testcase_09 WA -
testcase_10 AC 61 ms
66,044 KB
testcase_11 AC 332 ms
117,304 KB
testcase_12 AC 291 ms
106,000 KB
testcase_13 WA -
testcase_14 AC 329 ms
106,096 KB
testcase_15 AC 261 ms
105,408 KB
testcase_16 AC 300 ms
102,280 KB
testcase_17 AC 333 ms
105,396 KB
testcase_18 WA -
testcase_19 AC 299 ms
105,796 KB
testcase_20 WA -
testcase_21 AC 292 ms
108,380 KB
testcase_22 AC 360 ms
117,692 KB
testcase_23 AC 379 ms
102,312 KB
testcase_24 AC 380 ms
117,692 KB
testcase_25 AC 36 ms
53,460 KB
testcase_26 AC 35 ms
53,460 KB
testcase_27 AC 414 ms
105,868 KB
testcase_28 AC 382 ms
105,860 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]
    if H2[-1] == 0:
        print(w % n)
        continue
    if W2[-1] == 0:
        print(h % n)
        continue

    mi = min((h - 1) // H2[-1], (w - 1) // 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 % n)
0