結果

問題 No.2716 Falcon Method
ユーザー shinchanshinchan
提出日時 2024-04-05 22:06:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,848 bytes
コンパイル時間 2,393 ms
コンパイル使用メモリ 205,488 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:06:28
合計ジャッジ時間 6,549 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 143 ms
6,676 KB
testcase_22 WA -
testcase_23 AC 212 ms
6,676 KB
testcase_24 AC 193 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto&& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<ll> vr, vd;
    rep(i, n) {
        if(s[i] == 'R') vr.pb(i);
        else vd.pb(i);
    }
    rep(_, q) {
        ll h, w, p;
        cin >> h >> w >> p;
        ll ans = INF;
        int id = -1;
        if((int)vr.size()) {
            ll idx = lower_bound(all(vr), p) - vr.begin();
            if((ll)vr.size() - idx >= w) {
                ans = min(ans, vr[idx + w - 1] + 1);
            } else {
                w -= (ll)vr.size() - idx;
                ll num = w / (ll)vr.size();
                ll r = w % (ll)vr.size();
                if(r == 0) {
                    ans = min(ans, n + (num - 1) * n + vr.back() + 1);
                } else {
                    ans = min(ans, n + num * n + vr[r - 1] + 1);
                }
            }
        }
        if((int)vd.size()) {
            ll idx = lower_bound(all(vd), p) - vd.begin();
            if((ll)vd.size() - idx >= h) {
                ans = min(ans, vd[idx + h - 1] + 1);
            } else {
                w -= (ll)vd.size() - idx;
                ll num = h / (ll)vd.size();
                ll r = h % (ll)vd.size();
                if(r == 0) {
                    ans = min(ans, n + (num - 1) * n + vd.back() + 1);
                } else {
                    ans = min(ans, n + num * n + vd[r - 1] + 1);
                }
            }
        }
        cout << ans % n << endl;
    }
    return 0;
}
0