結果
問題 | No.2716 Falcon Method |
ユーザー |
👑 |
提出日時 | 2024-04-07 10:56:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 376 ms / 2,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 520 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 117,928 KB |
最終ジャッジ日時 | 2024-10-01 04:25:17 |
合計ジャッジ時間 | 7,490 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
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)