結果

問題 No.2716 Falcon Method
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-04-06 01:00:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 815 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 2,843 ms
コンパイル使用メモリ 206,904 KB
実行使用メモリ 14,312 KB
最終ジャッジ日時 2024-04-06 01:00:55
合計ジャッジ時間 14,380 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 4 ms
6,676 KB
testcase_07 AC 4 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 4 ms
6,676 KB
testcase_10 AC 4 ms
6,676 KB
testcase_11 AC 603 ms
13,756 KB
testcase_12 AC 441 ms
13,764 KB
testcase_13 AC 358 ms
13,936 KB
testcase_14 AC 614 ms
12,060 KB
testcase_15 AC 403 ms
13,400 KB
testcase_16 AC 536 ms
12,104 KB
testcase_17 AC 600 ms
12,508 KB
testcase_18 AC 745 ms
12,936 KB
testcase_19 AC 566 ms
11,912 KB
testcase_20 AC 458 ms
13,252 KB
testcase_21 AC 583 ms
12,320 KB
testcase_22 AC 638 ms
14,312 KB
testcase_23 AC 815 ms
14,312 KB
testcase_24 AC 812 ms
14,312 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 772 ms
14,312 KB
testcase_28 AC 745 ms
14,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    fast_io();
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<vector<long long>> cum(n + 1, vector<long long>(2));
    for (int i = 0; i < n; i++) {
        cum[i + 1][0] = cum[i][0] + (s[i] == 'D');
        cum[i + 1][1] = cum[i][1] + (s[i] == 'R');
    }
    auto get = [&](int l, int r, int c) {
        r -= l / n;
        l %= n;
        return cum[n][c] * (r / n - l / n) + cum[r % n][c] - cum[l][c];
    };
    for (; q--;) {
        long long h, w, p;
        cin >> h >> w >> p;
        long long ok = p - 1, ng = p + h + w;
        while (abs(ok - ng) > 1) {
            long long mid = (ok + ng) / 2;
            if (get(p, mid, 0) >= h || get(p, mid, 1) >= w) {
                ng = mid;
            } else {
                ok = mid;
            }
        }
        cout << ng % n << endl;
    }
}
0